package avicit.im.lantop.basic.archiveclassmanager.action.service.impl;

import avicit.cbb.billdefine.service.BillDefineManagerIntfsService;
import avicit.cbb.businessclass.fondsmanage.action.DBConnectionCustomManager;
import avicit.cbb.elefileupdown.service.FileUploadIntfsService;
import avicit.cbb.fondsmanage.service.CbbFondsDbIntfsService;
import avicit.cbb.tabledefine.service.CommTableManagerIntfsService;
import avicit.cbb.techclass.bigsave.action.MongoDBManager;
import avicit.cbb.techclass.billdefine.domain.CbbTabForm;
import avicit.cbb.techclass.billdefine.domain.CbbTabFormConfig;
import avicit.cbb.techclass.billdefine.domain.CbbTabFormNode;
import avicit.cbb.techclass.dxcc.JProperties;
import avicit.cbb.techclass.dxcc.S3Service;
import avicit.cbb.techclass.elefileconvert.service.impl.JProperties;
import avicit.cbb.techclass.elefileupdown.domain.CbbDocRelation;
import avicit.cbb.techclass.elefileupdown.service.FileUploadEvent;
import avicit.cbb.techclass.elefileupdown.service.FileUploadService;
import avicit.cbb.techclass.tabledefine.commtablemanager.action.CommTableSysFieldLoader;
import avicit.cbb.techclass.tabledefine.commtablemanager.domain.CbbTabColumns;
import avicit.cbb.techclass.tabledefine.commtablemanager.domain.CbbTables;
import avicit.cbb.techclass.tabledefine.commtablemanager.service.impl.CbbArchiveClassRestClient;
import avicit.im.common.util.DynamicExeMain;
import avicit.im.lantop.archiveclassmanager.service.ArchiveClassManagerIntfsService;
import avicit.im.lantop.basic.archiveclassmanager.action.service.BillDefineManagerIntfsService;
import avicit.im.lantop.common.StringUtil;
import avicit.platform6.api.syslookup.SysLookupAPI;
import avicit.platform6.api.syslookup.dto.SysLookupSimpleVo;
import avicit.platform6.api.syslookup.impl.SysLookupAPImpl;
import avicit.platform6.api.sysuser.SysDeptAPI;
import avicit.platform6.api.sysuser.SysUserAPI;
import avicit.platform6.api.sysuser.dto.SysDept;
import avicit.platform6.api.sysuser.dto.SysDeptTl;
import avicit.platform6.api.sysuser.dto.SysUser;
import avicit.platform6.commons.utils.ComUtil;
import avicit.platform6.commons.utils.FileUtil;
import avicit.platform6.commons.utils.JsonUtils;
import avicit.platform6.commons.utils.PojoUtil;
import avicit.platform6.core.dao.Paging;
import avicit.platform6.core.dao.hibernate.CommonHibernateDao2;
import avicit.platform6.core.jdbc.JdbcAvicit;
import avicit.platform6.core.jdbc.Page;
import avicit.platform6.core.properties.PlatformConstant.OpResult;
import avicit.platform6.core.properties.PlatformConstant.OpType;
import avicit.platform6.core.properties.PlatformProperties;
import avicit.platform6.core.rest.client.RestClient;
import avicit.platform6.core.rest.msg.ResponseMsg;
import avicit.platform6.core.rest.msg.ResponseStatus;
import avicit.platform6.core.spring.SpringFactory;
import avicit.platform6.fastdfs.fastdfs.ClientGlobal;
import avicit.platform6.fastdfs.utils.FastDfsUtil;
import avicit.platform6.modules.system.sysfileupload.domain.SysFileUpload;
import avicit.platform6.modules.system.sysfileupload.service.SysFileUploadService;
import avicit.platform6.modules.system.syslog.service.LogBaseFactory;
import avicit.platform6.modules.system.syslog.service.SysLogUtil;
import com.alibaba.fastjson.JSON;
import com.amazonaws.services.s3.AmazonS3;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.JSONTokener;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import javax.ws.rs.core.GenericType;
import java.io.*;
import java.math.BigDecimal;
import java.security.MessageDigest;
import java.sql.Date;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Map.Entry;

/**
 * <p>
 * 金航数码科技有限责任公司
 * </p>
 * <p>
 * 作者：朱锋
 * </p>
 * <p>
 * 邮箱：zhufeng@avicit.com
 * </p>
 * <p>
 * 创建时间： 2014-9-25 上午10:36:22
 * </p>
 * <p>
 * 类说明：表单自定义模块实现类
 * </p>
 * <p>
 * 修改记录：
 * </p>
 */
@SuppressWarnings({"unchecked","rawtypes","deprecation","static-access"})
@Service
public class BillDefineManagerIntfsServiceImpl implements BillDefineManagerIntfsService {

	@Autowired
	private CommonHibernateDao2 hibernateDao;
	@Autowired(required = false)
	private JdbcAvicit jdbcAvicit;
	@Autowired(required = true)
    CommTableManagerIntfsService commTableManagerIntfsService;
	@Autowired(required = false)
	CbbFondsDbIntfsService cbbFondsDbIntfsService;
	@Resource
	FileUploadEvent fileUploadEvent;
	@Autowired
	private ArchiveClassManagerIntfsService archiveClassManagerIntfsService;
	@Resource
	private FileUploadService fileUploadService;
	@Autowired(required = false)
	FileUploadIntfsService fileUploadIntfsService;
	@Autowired(required = true)
	private SysUserAPI userLoader;
	@Autowired(required = true)
	private SysDeptAPI deptLoader;
	@Autowired(required = true)
	private MongoDBManager mongoDBManager;
	private SysFileUploadService sysFileUploadService = SpringFactory.getBean(SysFileUploadService.class);
	// 获取存储方式
	public static final String SAVE_TYPE = JProperties.getFileProperties("savetype");
	public static final String doccenterPath = PlatformProperties.getProperty("doccenter.path");// 静态路径
	// fastdfs相关
	private static char hexdigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};

	public void init_() throws Exception {
		String fdfsClientConfigFilePath = "C:/fileconvert/cfg/fdfs_client.conf";
		ClientGlobal.init(fdfsClientConfigFilePath);
	}

	@Autowired(required = true)
	private CommTableSysFieldLoader commTableSysFieldLoader;
	SysLookupAPI upLoader = SpringFactory.getBean(SysLookupAPImpl.class); // 加载通用代码对象

	/**
	 * 创建表单信息
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId·
	 * @param nodeId
	 * @param nodeName
	 * @param tableId
	 * @throws Exception
	 *             void
	 * @throws
	 */
	@Override
	public void createCbbTabFormByIntfs(String orgId, String deptId, String sysId, String nodeId, String nodeName, String tableId) throws Exception {
		// 1.给tabForm表新增记录
		String formId = ComUtil.getId();
		CbbTabForm cbbTabForm = new CbbTabForm();
		cbbTabForm.setId(formId);
		cbbTabForm.setFormName(nodeName + "_表单");
		cbbTabForm.setFormIsDefalt("Y");
		cbbTabForm.setOrgId(orgId);
		cbbTabForm.setDeptId(deptId);
		cbbTabForm.setSysId(sysId);
		PojoUtil.setSysProperties(cbbTabForm, OpType.insert);
		hibernateDao.save(cbbTabForm);
		SysLogUtil.log(cbbTabForm, null, OpType.insert, OpResult.success);
		// 2.给CBB_TAB_FORM_CONFIG表新增记录
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT T.ID,T.COL_ORDER,T.ATTRIBUTE_11\n");
		sbSql.append("  FROM CBB_TAB_COLUMNS T\n");
		sbSql.append(" WHERE T.TABLE_ID = '" + tableId + "' AND T.COL_IS_DISPLAY = 'Y'\n");
		List<Object[]> objList = hibernateDao.findBySQL(sbSql.toString());
		for (int i = 0; i < objList.size(); i++) {
			String columnId = String.valueOf(objList.get(i)[0]);// 列ID
			String colOrder = String.valueOf(objList.get(i)[1]);// 表单顺序
			String colTabOrder = String.valueOf(objList.get(i)[2]);// 表格顺序
			String formConfigId = ComUtil.getId();
			CbbTabFormConfig cbbTabFormConfig = new CbbTabFormConfig();
			cbbTabFormConfig.setId(formConfigId);
			cbbTabFormConfig.setFormId(formId);
			cbbTabFormConfig.setColumnId(columnId);
			BigDecimal formVertical = new BigDecimal(1);
			cbbTabFormConfig.setFormVertical(formVertical);
			BigDecimal formHorizontal = new BigDecimal(1);
			cbbTabFormConfig.setFormHorizontal(formHorizontal);
			BigDecimal colOrderb = new BigDecimal(Integer.parseInt(colOrder));
			cbbTabFormConfig.setAttribute11(colOrderb);
			BigDecimal colTabOrderb = new BigDecimal(Integer.parseInt(colTabOrder));
			cbbTabFormConfig.setAttribute12(colTabOrderb);
			cbbTabFormConfig.setOrgId(orgId);
			cbbTabFormConfig.setDeptId(deptId);
			cbbTabFormConfig.setSysId(sysId);
			PojoUtil.setSysProperties(cbbTabFormConfig, OpType.insert);
			hibernateDao.save(cbbTabFormConfig);
			SysLogUtil.log(cbbTabFormConfig, null, OpType.insert, OpResult.success);
		}
		// 3.给获取记录ID
		String tabNodeId = commTableManagerIntfsService.getCbbTabNodeIdByIntfs(orgId, deptId, sysId, nodeId, tableId);
		// 4.给CBB_TAB_FORM_NODE新增记录
		String formNodeId = ComUtil.getId();
		CbbTabFormNode cbbTabFormNode = new CbbTabFormNode();
		cbbTabFormNode.setId(formNodeId);
		cbbTabFormNode.setTabNodeId(tabNodeId);
		cbbTabFormNode.setFormId(formId);
		cbbTabFormNode.setOrgId(orgId);
		cbbTabFormNode.setDeptId(deptId);
		cbbTabFormNode.setSysId(sysId);
		PojoUtil.setSysProperties(cbbTabFormNode, OpType.insert);
		hibernateDao.save(cbbTabFormNode);
		SysLogUtil.log(cbbTabFormNode, null, OpType.insert, OpResult.success);
	}

	/**
	 * 获取表单所有业务数据
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getFormDatasByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId) throws Exception {
		CbbTables cbbTables = getCbbTablesById(tableId);// 根据tableId获取基本表对象
		List<Map<String, Object>> listDatas = new ArrayList<Map<String, Object>>();
		List<Map<String, Object>> listCname = commTableManagerIntfsService.getCbbTabColumnsByIsAllByIntfs(orgId, deptId, sysId, tableId, "Y");// 所有字段名称集合
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT * FROM " + cbbTables.getTableName());
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			rs = statement.executeQuery(sbSql.toString());
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				// 循环字段集合添加数据
				for (int i = 0; i < listCname.size(); i++) {
					Map<String, Object> colMap = listCname.get(i);
					String cName = String.valueOf(colMap.get("COL_NAME"));
					map.put(cName, rs.getObject(cName));
				}
				listDatas.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return listDatas;
	}

	/**
	 * 根据数据ID，获取业务数据
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param dataId
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getFormSingleDataByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, String dataId) throws Exception {
		CbbTables cbbTables = getCbbTablesById(tableId);// 根据tableId获取基本表对象
		List<Map<String, Object>> listDatas = new ArrayList<Map<String, Object>>();
		List<Map<String, Object>> listCname = commTableManagerIntfsService.getCbbTabColumnsByIsAllByIntfs(orgId, deptId, sysId, tableId, "Y");// 所有字段名称集合
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT * FROM " + cbbTables.getTableName() + " WHERE ID = '" + dataId + "'");
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			rs = statement.executeQuery(sbSql.toString());
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				// 循环字段集合添加数据
				for (int i = 0; i < listCname.size(); i++) {
					Map<String, Object> colMap = listCname.get(i);
					String cName = String.valueOf(colMap.get("COL_NAME"));
					map.put(cName, rs.getObject(cName));
				}
				listDatas.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return listDatas;
	}

	/**
	 * 根据记录ID删除记录信息
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param dataId
	 * @param params
	 * @throws Exception void
	 * @throws
	 */
	@Override
	public void deleteRecordByDataIdByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, String dataId, Map<String, Object> params) throws Exception {
		CbbTables cbbTables = getCbbTablesById(tableId);
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("DELETE FROM " + cbbTables.getTableName() + " WHERE ID = '" + dataId + "'");
		String modleName = "XXX模块";
		if (params.containsKey("modleName")) {
			modleName = (String) params.get("modleName");
		}
		executeJdbc(sysId, sbSql.toString(), "delete", orgId, deptId, modleName);// JDBC执行该方法
		// 调用删除附件等关系表方法
		this.deleteAttachmentAndRelationAndMarkerById(dataId);
	}

	/**
	 * 根据记录IDS批量删除记录信息
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param dataIds
	 * @throws Exception
	 *             void
	 * @throws
	 */
	@Override
	public void deleteRecordByDataIdsByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, String dataIds, Map<String, Object> param) throws Exception {
		/*String modleName = "XXX模块";
		if (param.containsKey("modleName")) {
			modleName = (String) param.get("modleName");
		}*/
		String[] ids = dataIds.split(";");
		// -----jdbc批量删除---zyh
		if (ids.length > 0) {
			CbbTables cbbTables = this.getCbbTablesById(tableId);
			// 连接池
			DBConnectionCustomManager connectionMan = null;
			String poolName = orgId + "_" + sysId;
			Connection conn = null;
			PreparedStatement ps = null;
			try {
				// 实例化连接池
				connectionMan = DBConnectionCustomManager.getInstance(poolName);
				// 获取连接
				conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
				conn.setAutoCommit(false);
				StringBuffer deleteSql = new StringBuffer();
				deleteSql.append("DELETE FROM " + cbbTables.getTableName() + " WHERE ID = ?");
				ps = conn.prepareStatement(deleteSql.toString());
				for (int i = 0; i < ids.length; i++) {
					ps.setString(1, ids[i]);
					ps.addBatch();
					// if (i != 0 && i % 500 == 0) {
					// ps.executeBatch();
					// }
				}
				ps.executeBatch();
				conn.commit();
				// 原纪录日志的,现在都放在业务模块纪录日志
				// 删除附件信息,关系表信息,缩略图信息
				this.deleteAttachmentAndRelationAndMarkerById(dataIds);
			} catch (Exception e) {
				conn.rollback();
				e.printStackTrace();
				throw new Exception("数据库操作异常，请联系管理员！");
			} finally {
				if (ps != null) {
					try {
						ps.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (conn != null) {
					try {
						conn.setAutoCommit(true);
						connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
	}

	/**
	 * 根据业务状态等获取业务数据
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param mapObj
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getFormDatasByStatusByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, Map<String, Object> mapObj) throws Exception {
		List<Map<String, Object>> listDatas = new ArrayList<Map<String, Object>>();
		List<Map<String, Object>> listCname = commTableManagerIntfsService.getCbbTabColumnsByIsAllByIntfs(orgId, deptId, sysId, tableId, "Y");// 所有字段名称集合
		CbbTables cbbTables = getCbbTablesById(tableId);
		StringBuffer sbSqlData = new StringBuffer();
		sbSqlData.append("SELECT * FROM " + cbbTables.getTableName() + " WHERE 1 = 1");
		Iterator iterator = mapObj.keySet().iterator();
		while (iterator.hasNext()) {
			String colName = String.valueOf(iterator.next());
			String value = String.valueOf(mapObj.get(colName));
			String colType = "";
			colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
			if ("string".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlData.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
				} else {
					sbSqlData.append(" AND " + colName + "='" + value + "'");
				}
			} else if ("integer".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlData.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
				} else {
					sbSqlData.append(" AND " + colName + "=" + value);
				}
			} else if ("date".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlData.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
				} else {
					sbSqlData.append(" AND " + colName + "= TO_DATE('" + value + "','yyyy-MM-dd')");
				}
			} else if ("float".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlData.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
				} else {
					sbSqlData.append(" AND " + colName + "=" + value);
				}
			} else if ("clob".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlData.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
				} else {
					sbSqlData.append(" AND DBMS_LOB.SUBSTR(" + colName + ",32767) like '%" + value + "%'");
				}
			}
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			rs = statement.executeQuery(sbSqlData.toString());
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				// 循环字段集合添加数据
				for (int i = 0; i < listCname.size(); i++) {
					Map<String, Object> colMap = listCname.get(i);
					String cName = String.valueOf(colMap.get("COL_NAME"));
					map.put(cName, rs.getObject(cName));
				}
				listDatas.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return listDatas;
	}

	/**
	 * 添加业务数据
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param mapObj
	 * @throws Exception
	 *             String （记录ID）
	 * @throws
	 */
	@Override
	public String insertRecordByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, Map<String, Object> mapObj, String loginUserId, String loginIp) throws Exception {
		// 构造参数集合
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("tableId", tableId);
		param.put("mapObj", mapObj);
		param.put("loginUserId", loginUserId);
		param.put("loginIp", loginIp);
		param.put("modleName", mapObj.get("modleName"));
		// 执行添加方法
		String id = insertRecordByConfigByIntfs(orgId, deptId, sysId, param);
		return id;
	}

	/**
	 * 根据IDS，批量修改业务数据（断开表间数据关系）
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param dataIds
	 * @throws Exception
	 *             void
	 * @throws
	 */
	@Override
	public void updateDisconnectRecordByDataIdsByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, String dataIds, Map<String, Object> params) throws Exception {
		CbbTables cbbTables = getCbbTablesById(tableId);
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("UPDATE " + cbbTables.getTableName() + " SET PARENT_ID = '' WHERE ID IN (");
		String[] dataS = dataIds.split(";");
		for (int i = 0; i < dataS.length; i++) {
			sbSql.append("'" + dataS[i] + "',");
		}
		String sql = sbSql.substring(0, sbSql.length() - 1) + ")";
		String modleName = "XXX模块";
		if (params.containsKey("modleName")) {
			modleName = (String) params.get("modleName");
		}
		// JDBC实现更新
		executeJdbc(sysId, sql, "update", orgId, deptId, modleName);
	}

	/**
	 * 根据IDS，批量修改业务数据（建立案卷级和文件级数据关系）
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param ajjDataId
	 * @param wjjDataIds
	 * @throws Exception
	 *             void
	 * @throws
	 */
	@Override
	public void updateRecordByAjjDataIdByIntfs(String orgId, String deptId, String sysId, String nodeId, String ajjDataId, String wjjDataIds, Map<String, Object> params) throws Exception {
		String modleName = "XXX模块";
		if (params.containsKey("modleName")) {
			modleName = (String) params.get("modleName");
		}
		String[] wjjdataId = wjjDataIds.split(";");
		// 获取文件级表名
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT C.TABLE_ID\n");
		sbSql.append("  FROM CBB_TAB_NODE C\n");
		sbSql.append(" WHERE C.TAB_ORDER = (SELECT MAX(T.TAB_ORDER) FROM CBB_TAB_NODE T)\n");
		sbSql.append("   AND C.NODE_ID = '" + nodeId + "'\n");
		sbSql.append("   AND C.SYS_ID = '" + sysId + "'");
		List<Object> objList = hibernateDao.findBySQL(sbSql.toString());
		String tableId = "";
		if (objList.size() != 0) {
			tableId = String.valueOf(objList.get(0));
		}
		CbbTables cbbTables = getCbbTablesById(tableId);
		String tableName = cbbTables.getTableName();
		for (int i = 0; i < wjjdataId.length; i++) {
			String wid = wjjdataId[i];
			StringBuffer sbSqlup = new StringBuffer();
			sbSqlup.append("UPDATE " + tableName + " SET PARENT_ID = '" + ajjDataId + "' WHERE ID = '" + wid + "'");
			// JDBC实现更新
			executeJdbc(sysId, sbSqlup.toString(), "update", orgId, deptId, modleName);
		}
	}

	/**
	 * 根据数据ID修改业务数据状态等（单一数据修改）
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param mapObj
	 * @param dataId
	 * @param loginUserId
	 * @param loginIp
	 * @param version
	 * @throws Exception
	 *             void
	 */
	@Override
	public void updateRecordByDataIdByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, Map<String, Object> mapObj, String dataId, Map<String, Object> params) throws Exception {
		String modleName = "XXX模块";
		if (params.containsKey("modleName")) {
			modleName = (String) params.get("modleName");
		}
		CbbTables cbbTables = getCbbTablesById(tableId);
		StringBuffer sbSqlup = new StringBuffer();
		sbSqlup.append("UPDATE " + cbbTables.getTableName() + " SET ");
		Iterator iterator = mapObj.keySet().iterator();
		while (iterator.hasNext()) {
			String colName = String.valueOf(iterator.next());
			String value = String.valueOf(mapObj.get(colName));
			String colType = "";
			colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
			if ("string".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlup.append(colName + " = NULL,");
				} else {
					// 单引号的转换
					value = value.replaceAll("'", "' || chr(39) || '");
					sbSqlup.append(colName + "='" + value + "',");
				}
			} else if ("integer".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlup.append(colName + " = NULL,");
				} else {
					sbSqlup.append(colName + "=" + value + ",");
				}
			} else if ("date".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlup.append(colName + " = NULL,");
				} else {
					sbSqlup.append(colName + "= TO_DATE('" + value + "','yyyy-MM-dd'),");
				}
			} else if ("float".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlup.append(colName + " = NULL,");
				} else {
					sbSqlup.append(colName + "=" + value + ",");
				}
			} else if ("blob".equals(colType)) {
				sbSqlup.append(colName + " = NULL,");
			} else if ("clob".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlup.append(colName + " = NULL,");
				} else {
					sbSqlup.append(colName + "= '" + value + "',");
				}
			}
		}
		String upSql = sbSqlup.substring(0, sbSqlup.length() - 1);
		upSql = upSql + " WHERE ID = '" + dataId + "'";
		if (mapObj.size() != 0) {
			// JDBC实现更新
			executeJdbc(sysId, upSql, "update", orgId, deptId, modleName);
		}
	}

	/**
	 * 根据IDS批量修改业务数据状态等（批量数据修改）
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param mapObj
	 * @param dataIds
	 * @param loginUserId
	 * @param loginIp
	 * @param version
	 * @throws Exception
	 *             void
	 */
	@Override
	public void updateRecordByDataIdsByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, Map<String, Object> mapObj, String dataIds, Map<String, Object> params) throws Exception {
		String modleName = "XXX模块";
		if (params.containsKey("modleName")) {
			modleName = (String) params.get("modleName");
		}
		String[] datas = dataIds.split(";");
		// 验证参数是否正确
		if (datas.length == 0 || mapObj.size() == 0) {
			throw new Exception("方法参数传递错误，请检查参数！");
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			CbbTables cbbTables = getCbbTablesById(tableId);
			StringBuffer sbSqlup = new StringBuffer();
			sbSqlup.append("UPDATE " + cbbTables.getTableName() + " SET ");
			Iterator iterator = mapObj.keySet().iterator();
			while (iterator.hasNext()) {
				String colName = String.valueOf(iterator.next());
				String value = String.valueOf(mapObj.get(colName));
				String colType = "";
				colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
				if ("string".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + "= NULL,");
					} else {
						// 单引号的转换
						value = value.replaceAll("'", "' || chr(39) || '");
						if("2cm".equals(value.replaceAll("' || chr(39) || '",""))||"4cm".equals(value.replaceAll("' || chr(39) || '",""))||("6cm").equals(value.replaceAll("' || chr(39) || '",""))||("8cm").equals(value.replaceAll("' || chr(39) || '",""))){
							value = value.replaceAll("c","");
							value = value.replaceAll("m","");
						}
						sbSqlup.append(colName + "='" + value + "',");
					}
				} else if ("integer".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + " = NULL,");
					} else {
						sbSqlup.append(colName + "=" + value + ",");
					}
				} else if ("date".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + "= NULL,");
					} else {
						sbSqlup.append(colName + "= TO_DATE('" + value + "','yyyy-MM-dd'),");
					}
				} else if ("float".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + "= NULL,");
					} else {
						sbSqlup.append(colName + "=" + value + ",");
					}
				} else if ("blob".equals(colType)) {
					sbSqlup.append(colName + " = NULL,");
				} else if ("clob".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + " = NULL,");
					} else {
						sbSqlup.append(colName + " ='" + value + "',");
					}
				}
			}
			String upSql = sbSqlup.substring(0, sbSqlup.length() - 1);
			upSql = upSql + " WHERE ID in ('"+dataIds+"')";
			statement.executeUpdate(upSql);
			SysLogUtil.log(modleName, "修改记录", OpType.update, OpResult.success, LogBaseFactory.getLogBase());
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

	/**
	 * 根据IDS批量修改业务数据状态等（批量数据修改）重写
	 *
	 * @author zhaoxiaolong
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param mapObj
	 * @param dataIds
	 * @param loginUserId
	 * @param loginIp
	 * @param version
	 * @throws Exception
	 *             void
	 */
	@Override
	public void updateRecordByDataIdsByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, Map<String, Object> mapObj, String dataIds, Map<String, Object> params,String arg1) throws Exception {
		String modleName = "XXX模块";
		if (params.containsKey("modleName")) {
			modleName = (String) params.get("modleName");
		}
		String[] datas = dataIds.split(";");
		// 验证参数是否正确
		if (datas.length == 0 || mapObj.size() == 0) {
			throw new Exception("方法参数传递错误，请检查参数！");
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			CbbTables cbbTables = getCbbTablesById(tableId);
			StringBuffer sbSqlup = new StringBuffer();
			sbSqlup.append("UPDATE " + cbbTables.getTableName() + " SET ");
			Iterator iterator = mapObj.keySet().iterator();
			while (iterator.hasNext()) {
				String colName = String.valueOf(iterator.next());
				String value = String.valueOf(mapObj.get(colName));
				String colType = "";
				colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
				if ("string".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + "= NULL,");
					} else {
						// 单引号的转换
						value = value.replaceAll("'", "' || chr(39) || '");
						if("2cm".equals(value.replaceAll("' || chr(39) || '",""))||"4cm".equals(value.replaceAll("' || chr(39) || '",""))||("6cm").equals(value.replaceAll("' || chr(39) || '",""))||("8cm").equals(value.replaceAll("' || chr(39) || '",""))){
							value = value.replaceAll("c","");
							value = value.replaceAll("m","");
						}
						sbSqlup.append(colName + "='" + value + "',");
					}
				} else if ("integer".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + " = NULL,");
					} else {
						sbSqlup.append(colName + "=" + value + ",");
					}
				} else if ("date".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + "= NULL,");
					} else {
						sbSqlup.append(colName + "= TO_DATE('" + value + "','yyyy-MM-dd'),");
					}
				} else if ("float".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + "= NULL,");
					} else {
						sbSqlup.append(colName + "=" + value + ",");
					}
				} else if ("blob".equals(colType)) {
					sbSqlup.append(colName + " = NULL,");
				} else if ("clob".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + " = NULL,");
					} else {
						sbSqlup.append(colName + " ='" + value + "',");
					}
				}
			}
			String upSql = sbSqlup.substring(0, sbSqlup.length() - 1);
			upSql = upSql + " WHERE ID in ("+dataIds+")";
			statement.executeUpdate(upSql);
			SysLogUtil.log(modleName, "修改记录", OpType.update, OpResult.success, LogBaseFactory.getLogBase());
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

	/**
	 * 根据数据ID，获取编辑或详细，字段和数据（不带参数集合）
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param dataId
	 * @param flag
	 * @return
	 * @throws Exception List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getEditOrDetailFieldsAndDataByIntfs(String orgId, String deptId, String sysId, String tableId, String dataId, String flag) throws Exception {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		CbbTables cbbTables = getCbbTablesById(tableId);
		List<CbbTabColumns> listc = getFormShowTableList(tableId, dataId, cbbTables.getTableName(), flag, sysId, orgId, deptId, "");// 基本字段
		for (int i = 0; i < listc.size(); i++) {
			CbbTabColumns cbbTabColumns = listc.get(i);
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("ID", cbbTabColumns.getId());
			map.put("TABLE_ID", cbbTabColumns.getTableId());
			map.put("COL_NAME", cbbTabColumns.getColName());
			map.put("COL_LABEL", cbbTabColumns.getColLabel());
			map.put("COL_TYPE", cbbTabColumns.getColType());
			map.put("COL_LENGTH", cbbTabColumns.getColLength());
			map.put("COL_DECIMAL", cbbTabColumns.getColDecimal());
			map.put("COL_IS_SYS", cbbTabColumns.getColIsSys());
			map.put("COL_ORDER", cbbTabColumns.getColOrder());
			map.put("COL_IS_MUST", cbbTabColumns.getColIsMust());
			map.put("COL_IS_VISIBLE", cbbTabColumns.getColIsVisible());
			map.put("COL_IS_SEARCH", cbbTabColumns.getColIsSearch());
			map.put("COL_IS_EDIT", cbbTabColumns.getColIsEdit());
			map.put("COL_IS_TAB_VISIBLE", cbbTabColumns.getColIsTabVisible());
			map.put("COL_IS_DETAIL", cbbTabColumns.getColIsDetail());
			map.put("COL_DROPDOWN_TYPE", cbbTabColumns.getColDropdownType());
			map.put("COL_GENE_METHOD", cbbTabColumns.getColGeneMethod());
			map.put("COL_RULE_NAME", cbbTabColumns.getColRuleName());
			map.put("COL_RULE_TITLE", cbbTabColumns.getColRuleTitle());
			map.put("CUSTOM_PATH", cbbTabColumns.getCustomPath());
			map.put("REMARK", cbbTabColumns.getRemark());
			map.put("IS_COMM_FIELD", cbbTabColumns.getIsCommField());
			if ("date".equals(cbbTabColumns.getColType()) && !"".equals(cbbTabColumns.getColValue()) && null != cbbTabColumns.getColValue()) {
				String date = cbbTabColumns.getColValue().substring(0, 10);
				map.put("COL_VALUE", date);
			} else {
				map.put("COL_VALUE", cbbTabColumns.getColValue());
			}
			map.put("COL_VALUE_NAME", cbbTabColumns.getColValueName());
			list.add(map);
		}
		return list;
	}

	/**
	 * 根据数据ID，获取编辑或详细，字段和数据
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param dataId
	 * @param flag
	 * @param params(p1: key=nodeId)
	 * @return
	 * @throws Exception List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getEditOrDetailFieldsAndDataByIntfs(String orgId, String deptId, String sysId, String tableId, String dataId, String flag, Map<String, Object> params) throws Exception {
		String languageCode = "";// 当前语言code
		if (null != params && params.containsKey("languageCode")) {
			languageCode = String.valueOf(params.get("languageCode"));
		} else {
			throw new Exception("调用接口时，“languageCode”参数不存在，请检查！");
		}
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		CbbTables cbbTables = getCbbTablesById(tableId);
		List<CbbTabColumns> listc = getFormShowTableList(tableId, dataId, cbbTables.getTableName(), flag, sysId, orgId, deptId, (String) params.get("nodeId"));// 基本字段
		for (int i = 0; i < listc.size(); i++) {
			CbbTabColumns cbbTabColumns = listc.get(i);
			String languageLabel = this.commTableManagerIntfsService.getColumnLabelByColumnIdAndLanguageCode(cbbTabColumns.getId(), languageCode);
			// 如果是中文code , 并且label为空,则用系统默认label显示
			if ("zh_CN".equals(languageCode) && (null == languageLabel || "".equals(languageLabel))) {
				languageLabel = cbbTabColumns.getColLabel();
			}
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("ID", cbbTabColumns.getId());
			map.put("TABLE_ID", cbbTabColumns.getTableId());
			map.put("COL_NAME", cbbTabColumns.getColName());
			map.put("COL_LABEL", languageLabel);
			map.put("COL_TYPE", cbbTabColumns.getColType());
			map.put("COL_LENGTH", cbbTabColumns.getColLength());
			map.put("COL_DECIMAL", cbbTabColumns.getColDecimal());
			map.put("COL_IS_SYS", cbbTabColumns.getColIsSys());
			map.put("COL_ORDER", cbbTabColumns.getColOrder());
			map.put("COL_IS_MUST", cbbTabColumns.getColIsMust());
			map.put("COL_IS_VISIBLE", cbbTabColumns.getColIsVisible());
			map.put("COL_IS_SEARCH", cbbTabColumns.getColIsSearch());
			map.put("COL_IS_EDIT", cbbTabColumns.getColIsEdit());
			map.put("COL_IS_TAB_VISIBLE", cbbTabColumns.getColIsTabVisible());
			map.put("COL_IS_DETAIL", cbbTabColumns.getColIsDetail());
			map.put("COL_DROPDOWN_TYPE", cbbTabColumns.getColDropdownType());
			map.put("COL_GENE_METHOD", cbbTabColumns.getColGeneMethod());
			map.put("COL_RULE_NAME", cbbTabColumns.getColRuleName());
			map.put("COL_RULE_TITLE", cbbTabColumns.getColRuleTitle());
			map.put("CUSTOM_PATH", cbbTabColumns.getCustomPath());
			map.put("REMARK", cbbTabColumns.getRemark());
			map.put("IS_COMM_FIELD", cbbTabColumns.getIsCommField());
			if ("date".equals(cbbTabColumns.getColType()) && !"".equals(cbbTabColumns.getColValue()) && null != cbbTabColumns.getColValue()) {
				String date = cbbTabColumns.getColValue().substring(0, 10);
				map.put("COL_VALUE", date);
			} else {
				map.put("COL_VALUE", cbbTabColumns.getColValue());
			}
			map.put("COL_VALUE_NAME", cbbTabColumns.getColValueName());
			// 添加组合项规则
			String colGeneMethod = cbbTabColumns.getColGeneMethod();
			if ("4".equals(colGeneMethod)) { // 组合项
				String sourceId = cbbTabColumns.getId();// 源字段ID
				String recordId = "";
				if (null != params && params.containsKey("ortherMap")) {
					Map<String, Object> ortherMap = (Map<String, Object>) params.get("ortherMap");
					Iterator it = ortherMap.keySet().iterator();
					while (it.hasNext()) {
						String key = String.valueOf(it.next());
						recordId = String.valueOf(ortherMap.get(key));
					}
				}
				// 组合项信息字符串，页面解析进行填值
				String groupConfig = getConfigStr(sourceId, tableId, recordId);
				map.put("GROUP_CONFIG", groupConfig);
			}
			list.add(map);
		}
		return list;
	}

	/**
	 * 根据标识条件，获取字段信息
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param flag
	 *            （1-添加显示；2-列表显示；3-详细显示；4-查询显示）
	 * @param dataId
	 * @param params
	 *            参数列表
	 *            <ul>
	 *            <li>p1 : key = "ortherMap", 非必输 ,
	 *            Map类型，<兄弟表表ID(String)，兄弟表数据ID(String)>用于选择兄弟表组合项加载数据</li>
	 *            <li>p2 : currentUserId（String）当前用户ID, 必输</li>
	 *            <li>p3 : currentDeptId（String）当前部门ID, 必输</li>
	 *            <li>p4 : currentOrgCode（String）当前组织代码, 必输</li>
	 *            <li>p5 : userAuthsql（String）条件sql(其中包含用户权限sql), 非必输</li>
	 *            <li>p6 : wjIds（String）文件数据ID串（组卷新增案卷时有值）, 非必输</li>
	 *            <li>p7 : nodeId（String）节点ID，非必输</li>
	 *            </ul>
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getFieldsByConditionByIntfs(String orgId, String deptId, String sysId, String tableId, String flag, String dataId, Map<String, Object> params) throws Exception {
		String currentUserId = "";// 当前用户ID
		if (null != params && params.containsKey("currentUserId")) {
			currentUserId = String.valueOf(params.get("currentUserId"));
		} else {
			throw new Exception("调用接口时，“currentUserId”参数不存在，请检查！");
		}
		String languageCode = "";// 当前语言code
		if (null != params && params.containsKey("languageCode")) {
			languageCode = String.valueOf(params.get("languageCode"));
		} else {
			throw new Exception("调用接口时，“languageCode”参数不存在，请检查！");
		}
		String currentDeptId = "";// 当前部门ID
		if (null != params && params.containsKey("currentDeptId")) {
			currentDeptId = String.valueOf(params.get("currentDeptId"));
		} else {
			throw new Exception("调用接口时，“currentDeptId”参数不存在，请检查！");
		}
		String parentDataId = ""; // 父级数据id(顺带父级数据用)
		if (null != params && params.containsKey("parentDataId")) {
			parentDataId = (String) params.get("parentDataId");
		}
		String nodeId = "";//数据节点ID
		if (null != params && params.containsKey("nodeId")) {
			nodeId = (String) params.get("nodeId");
		}
		SysDept currentDept = deptLoader.getSysDeptBySysDeptId(deptId); // 上级部门代码
		SysDept paretnDept = deptLoader.getParentSysDeptBySysDeptId(currentDeptId); // 上级部门代码
		String parentDeptId = "";
		String parentDeptCode = "";
		if (null != paretnDept) {
			parentDeptId = this.deptLoader.getParentSysDeptIdBySysDeptId(currentDeptId); // 当前部门上级部门ID
			parentDeptCode = paretnDept.getDeptCode();
		} else {
			// 如果没有上级部门，那么取当前部门
			parentDeptId = deptId;
			parentDeptCode = currentDept.getDeptCode();
		}
		String currentOrgCode = "";// 当前组织代码
		if (null != params && params.containsKey("currentOrgCode")) {
			currentOrgCode = String.valueOf(params.get("currentOrgCode"));
		} else {
			throw new Exception("调用接口时，“currentOrgCode”参数不存在，请检查！");
		}
		String userAuthsql = String.valueOf(params.get("userAuthsql"));// 条件sql
		String wjIds = String.valueOf(params.get("wjIds"));// 文件数据ID串（组卷新增案卷时有值）
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		CbbTables cbbTables = getCbbTablesById(tableId);
		//List<CbbTabColumns> listc = getFormShowTableList(tableId, "", cbbTables.getTableName(), flag, sysId, orgId, deptId, nodeId);// 基本字段
		//SanXiaFiles update by huangjian  增加表格排序
		List<CbbTabColumns> listc = getFormShowTableListItera(params,tableId, "", cbbTables.getTableName(), flag, sysId, orgId, deptId, nodeId);// 基本字段
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		ResultSet xlRs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			for (int i = 0; i < listc.size(); i++) {
				CbbTabColumns cbbTabColumns = listc.get(i);
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("ID", listc.get(i).getId());
				map.put("TABLE_ID", cbbTabColumns.getTableId());
				map.put("COL_NAME", cbbTabColumns.getColName());
				String languageLabel = this.commTableManagerIntfsService.getColumnLabelByColumnIdAndLanguageCode(cbbTabColumns.getId(), languageCode);
				// 如果是中文code , 并且label为空,则用系统默认label显示
				if ("zh_CN".equals(languageCode) && (null == languageLabel || "".equals(languageLabel))) {
					languageLabel = cbbTabColumns.getColLabel();
				}
				map.put("COL_LABEL", languageLabel); // cbbTabColumns.getColLabel()
				map.put("COL_TYPE", cbbTabColumns.getColType());
				map.put("COL_LENGTH", cbbTabColumns.getColLength());
				map.put("COL_DECIMAL", cbbTabColumns.getColDecimal());
				map.put("COL_IS_SYS", cbbTabColumns.getColIsSys());
				map.put("COL_ORDER", cbbTabColumns.getColOrder());
				map.put("COL_IS_MUST", cbbTabColumns.getColIsMust());
				map.put("COL_IS_VISIBLE", cbbTabColumns.getColIsVisible());
				map.put("COL_IS_SEARCH", cbbTabColumns.getColIsSearch());
				map.put("COL_IS_EDIT", cbbTabColumns.getColIsEdit());
				map.put("COL_IS_TAB_VISIBLE", cbbTabColumns.getColIsTabVisible());
				map.put("COL_IS_DETAIL", cbbTabColumns.getColIsDetail());
				map.put("COL_DROPDOWN_TYPE", cbbTabColumns.getColDropdownType());
				map.put("COL_GENE_METHOD", cbbTabColumns.getColGeneMethod());
				map.put("COL_RULE_NAME", cbbTabColumns.getColRuleName());
				map.put("COL_RULE_TITLE", cbbTabColumns.getColRuleTitle());
				map.put("CUSTOM_PATH", cbbTabColumns.getCustomPath());
				map.put("REMARK", cbbTabColumns.getRemark());
				map.put("IS_COMM_FIELD", cbbTabColumns.getIsCommField());
				// 获取字段配置信息，添加到map里(colValue,colValueName)
				String colValue = "";
				String colValueName = "";
				String colDropdownType = cbbTabColumns.getColDropdownType();
				String colRuleName = cbbTabColumns.getColRuleName();
				String colGeneMethod = cbbTabColumns.getColGeneMethod();
				String colGeneMethodRule = cbbTabColumns.getColGeneMethodRule();
				String colType = cbbTabColumns.getColType();
				String colName= cbbTabColumns.getColName();
				String customPath = cbbTabColumns.getCustomPath();// 自定义URL
				if ("1".equals(colGeneMethod)) { // 默认值
					if ("1".equals(colDropdownType) || "2".equals(colDropdownType)) { // 参选、只选
						// 获取通用代码
						colValue = colGeneMethodRule;
					} else if ("3".equals(colDropdownType)) {
						if ("user".equals(colRuleName)) { // 选人
							if ("currentUser".equals(colGeneMethodRule)) {
								colValue = currentUserId;
								// 根据ID查找userName
								colValueName = getUserNameById(currentUserId);
							}
						} else if ("dept".equals(colRuleName)) { // 选部门
							if ("currentDept".equals(colGeneMethodRule)) { // 当前部门
								colValue = currentDeptId;
								// 根据ID查找userName
								colValueName = getDeptNameById(currentDeptId);
							} else if ("parentDept".equals(colGeneMethodRule)) {// 上级部门
								colValue = parentDeptId;
								// 根据ID查找userName
								colValueName = getDeptNameById(parentDeptId);
							}
						} else if ("custom".equals(colRuleName)) { // 自定义选择
							colValue = colGeneMethodRule;
							// 根据PATH查询相应的值
							colValueName = getCustomValue(colGeneMethodRule, customPath);
						}
					} else if ("0".equals(colDropdownType)) { // 普通字段
						if ("string".equals(colType) || "clob".equals(colType)) {
							if ("currentUser".equals(colGeneMethodRule)) { // 当前用户
								// 根据ID查找userName
								colValue = getUserNameById(currentUserId);
							} else if ("currentDeptId".equals(colGeneMethodRule)) { // 当前部门ID
								// 根据ID查找userName
								colValue = currentDeptId;
							} else if ("currentDeptName".equals(colGeneMethodRule)) { // 当前部门ID
								// 根据ID查找userName
								colValue = getDeptNameById(currentDeptId);
							} else if ("currentOrg".equals(colGeneMethodRule)) { // 当前组织代码
								// 根据ID查找userName
								colValue = currentOrgCode;
							} else if ("currentQzName".equals(colGeneMethodRule)) { // 当前全宗名称
								// 根据当前组织ID查找全宗名称
								List<Map<String, Object>> qzList = getQz(orgId);
								if(qzList.size() > 0){
									Map<String, Object> qzmap = qzList.get(0);
									colValue = String.valueOf(qzmap.get("GENERAL_NAME"));
								}else{
									colValue = "";
								}
							} else if ("currentQzCode".equals(colGeneMethodRule)) { // 当前全宗代码
								// 根据当前组织ID查找全宗代码
								List<Map<String, Object>> qzList = getQz(orgId);
								if(qzList.size() > 0){
									Map<String, Object> qzmap = qzList.get(0);
									colValue = String.valueOf(qzmap.get("GENERAL_BEN_CODE"));
								}else{
									colValue = "";
								}
							} else if ("currentNodeRemark".equals(colGeneMethodRule)) { // 当前数据节点备注
								// 根据节点ID查询当前数据节点备注
								List<Map<String, Object>> flList = getNodeRemarkByNodeId(nodeId);
								if(flList.size() > 0){
									Map<String, Object> flmap = flList.get(0);
									String remark = String.valueOf(flmap.get("REMARK"));//获取当前节点备注值
									if(null != remark && !"".equals(remark) && !"null".equals(remark)){
										String[] vas = remark.split(";");
										for (int j = 0; j < vas.length; j++) {
											String va = vas[j];
											String[] v = va.split("=");
											if(v.length == 2){
												if(!"".equals(v[0]) && (colName.toUpperCase()).equals(v[0].toUpperCase())){
													colValue = v[1];
												}
											}
										}
									}
								}else{
									colValue = "";
								}
							} else if ("parentDeptName".equals(colGeneMethodRule)) { // 上级部门名称
								colValue = getDeptNameById(parentDeptId);
								// 根据ID查找userName
								colValueName = getDeptNameById(parentDeptId);
							} else if ("parentDeptId".equals(colGeneMethodRule)) { // 上级部门ID
								colValue = parentDeptId;
								colValueName = parentDeptId;
							} else if ("parentDeptCode".equals(colGeneMethodRule)) { // 上级部门代码
								colValue = parentDeptCode;
								colValueName = parentDeptCode;
							} else {
								colValue = colGeneMethodRule;
							}
						} else if ("date".equals(colType)) {
							if ("currentDate".equals(colGeneMethodRule)) { // 当前时间
								java.util.Date dt = new java.util.Date();
								DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
								colValue = df.format(dt);
							}
						} else {
							colValue = colGeneMethodRule;
						}
					}
				}

					if ("2".equals(colGeneMethod)) { // 序列
						String bgh = "1:QZH;ARCHIVE_CLASSNO;YEAR; ARCHIVE_MANA_PERIOD";
						if (colName.equals("BGH") && (!bgh.equals(colGeneMethodRule) || "".equals(colGeneMethodRule))) {

						}else{
						String [] colNameArg = colGeneMethodRule.substring(2,colGeneMethodRule.length()).split(";"); // 获取保管号相关字段配置项
						StringBuffer screenSql = new StringBuffer();
						for (String colForName : colNameArg){
							colForName = colForName.trim();
							// 遍历保管号动态配置字段，获取字段对应的默认值，作为筛选条件
							for (CbbTabColumns cbbTab : listc){
								String cbbTabName = cbbTab.getColName();
								colForName=colForName;
								if(cbbTabName.equals(colForName)){
									String value = this.getValueByColGeneMethodRule(cbbTab.getColGeneMethodRule(),cbbTab.getColGeneMethod(),cbbTab.getColDropdownType(),cbbTab.getColType(),cbbTab.getOrgId(),nodeId,cbbTab.getColName());
									if(value!=null&&!value.equals("")){
										screenSql.append(" AND "+colForName+" = '"+value+"' ");
									}else {
										screenSql.append(" AND "+colForName+" IS NULL ");
									}
									break;
								}
							}
						}
						String dataSqlXL = "";
						if (colNameArg.length>0){
							// 权限sql，找最大记录
							dataSqlXL = "SELECT CASE WHEN MAX(TO_NUMBER(REGEXP_REPLACE(" + cbbTabColumns.getColName().toUpperCase() + ",'[^0-9]')))  IS NULL THEN 0 ELSE  MAX(TO_NUMBER(REGEXP_REPLACE(" + cbbTabColumns.getColName().toUpperCase() + ",'[^0-9]')))  END  " + cbbTabColumns.getColName().toUpperCase() + " FROM " + cbbTables.getTableName().toUpperCase() + " WHERE 1 = 1 "+screenSql.toString();
							//SanXiaFiles update by huangjian 防止保管号类型不一致报错
							// dataSqlXL = "SELECT NVL(MAX(BGH),1) BGH FROM " + cbbTables.getTableName().toUpperCase() + " WHERE 1 = 1 "+screenSql.toString();
							if (null != parentDataId && !"".equals(parentDataId)) {
								dataSqlXL += " AND PARENT_ID = '" + parentDataId + "'";
							}
							if (null != userAuthsql && !"".equals(userAuthsql) && !"null".equals(userAuthsql)) {
								dataSqlXL = dataSqlXL + userAuthsql;
							}
						}
						xlRs = statement.executeQuery(dataSqlXL.toString());
						while (xlRs.next()) {
							String dataValueXL = xlRs.getString(cbbTabColumns.getColName().toUpperCase());
							int count = Integer.valueOf(dataValueXL);
							dataValueXL = String.valueOf(count);
							if ("2".equals(colDropdownType)) { // 参选
								colValue = dataValueXL + colGeneMethodRule;
							} else if ("0".equals(colDropdownType)) { // 普通字段
								if ("string".equals(colType)) {
									colValue = stringConfig(dataValueXL, colGeneMethodRule.split(":")[0]);
								} else if ("integer".equals(colType)) {
									int cdataInteger = 0;
									if (null != dataValueXL && !"".equals(dataValueXL) && !"null".equals(dataValueXL)) {
										cdataInteger = Integer.parseInt(dataValueXL);
									}
									if (null != colGeneMethodRule && !"".equals(colGeneMethodRule) && !"null".equals(colGeneMethodRule)) {
										//sanxiaFiels create by  zbj 下面参数切割掉：之后字符串  2019.8.19
										cdataInteger = cdataInteger + Integer.parseInt(colGeneMethodRule.split(":")[0]);
										//end
									}
									colValue = String.valueOf(cdataInteger);
									// SanXiaFiles create by zhaoxiaolong 保管号整型处理 2019/12/28
									if (colName!=null&&colName.equals("BGH")){
										colValue = stringConfig(dataValueXL, colGeneMethodRule.split(":")[0]);
										map.put("COL_TYPE", "string");
									}
								} else if ("float".equals(colType)) {
									float cdataFloat = 0;
									if (null != dataValueXL && !"".equals(dataValueXL) && !"null".equals(dataValueXL)) {
										cdataFloat = Float.parseFloat(dataValueXL);
									}
									if (null != colGeneMethodRule && !"".equals(colGeneMethodRule) && !"null".equals(colGeneMethodRule)) {
										cdataFloat = cdataFloat + Float.parseFloat(colGeneMethodRule);
									}
									colValue = String.valueOf(cdataFloat);
								} else if ("clob".equals(colType)) {
									colValue = dataValueXL;
									if (null != colGeneMethodRule && !"".equals(colGeneMethodRule) && !"null".equals(colGeneMethodRule)) {
										colValue = colValue + colGeneMethodRule;
									}
								}
							}
						}
					}
				}
				if ("3".equals(colGeneMethod)) { // 顺带
					String geneMethodRule = cbbTabColumns.getColGeneMethodRule();
					String searchTableId = "";
					String searchColId = "";
					if (null == geneMethodRule || "".equals(geneMethodRule) || "null".equals(geneMethodRule)) {
						searchTableId = cbbTabColumns.getTableId();
						searchColId = cbbTabColumns.getId();
					} else {
						String[] geneMethodRules = geneMethodRule.split(",");
						searchTableId = geneMethodRules[0];
						searchColId = geneMethodRules[1];
					}
					CbbTables ct = this.getCbbTablesById(searchTableId);

					List<Map<String, Object>> columnList = this.commTableManagerIntfsService.getCbbColumnsByColIdByIntfs(searchColId);
					Map<String, Object> columnMap = new HashMap<String, Object>();
					if (columnList.size() > 0) {
						columnMap.putAll(columnList.get(0));
					}
					String searchDataId = "";
					if (searchTableId.equals(cbbTabColumns.getTableId())) {
						if (!"".equals(dataId)) {
							searchDataId = dataId;
						}
					} else {
						if (!"".equals(parentDataId)) {
							searchDataId = parentDataId;
						}
					}
					if (!"".equals(searchDataId)) {
						String dataValue = "";
						// 根据选中数据ID获取数据对象
						String dataSql = "SELECT T.* FROM " + ct.getTableName() + " T WHERE T.ID = '" + searchDataId + "'";
						rs = statement.executeQuery(dataSql.toString());
						while (rs.next()) {
							dataValue = rs.getString((String) columnMap.get("COL_NAME"));
							if (null != dataValue && !"".equals(dataValue) && !"null".equals(dataValue)) {
								if ("3".equals(colDropdownType)) {
									if ("user".equals(colRuleName)) { // 选人
										colValue = dataValue;
										colValueName = getUserNameById(dataValue);
										if ("".equals(colValueName)) {
											colValueName = colValue;
										}
									} else if ("dept".equals(colRuleName)) { // 选部门
										colValue = dataValue;
										colValueName = getDeptNameById(dataValue);
										if ("".equals(colValueName)) {
											colValueName = colValue;
										}
									} else if ("custom".equals(colRuleName)) { // 自定义选择
										colValueName = getCustomValue(dataValue, customPath);
									}
								} else { // 下拉类型，普通字段
									if ("date".equals(colType)) {
										if (null != dataValue && !"".equals(dataValue) && !"null".equals(dataValue)) {
											colValue = dataValue.substring(0, 10);
										} else {
											colValue = "";
										}
									} else {
										colValue = dataValue;
									}
								}
							}
						}
					}
				}
				if ("4".equals(colGeneMethod)) { // 组合项
					String sourceId = cbbTabColumns.getId();// 源字段ID
					String recordId = "";
					if (null != params && params.containsKey("ortherMap")) {
						Map<String, Object> ortherMap = (Map<String, Object>) params.get("ortherMap");
						Iterator it = ortherMap.keySet().iterator();
						while (it.hasNext()) {
							String key = String.valueOf(it.next());
							recordId = String.valueOf(ortherMap.get(key));
						}
					}
					// 组合项信息字符串，页面解析进行填值
					String groupConfig = getConfigStr(sourceId, tableId, recordId);
					map.put("GROUP_CONFIG", groupConfig);
				}
				if ("5".equals(colGeneMethod)) { // 组卷时新建案卷将配置为统计生成的字段值计算出来并在页面显示
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) {
						// 获取字段配置的统计生成信息
						String configSql = "SELECT T.GROUP_ORDER,T.TARGET_TABLE_ID,T.TARGET_COLUMN_ID,T.TARGET_INPUT,T.TARGET_COLUMN_OPERATION FROM CBB_TAB_COL_CONFIG_GROUP T WHERE T.SOURCE_TABLE_ID = '" + tableId + "' AND T.SOURCE_COLUMN_ID = '" + cbbTabColumns.getId() + "'";
						List<Object[]> configList = this.hibernateDao.findBySQL(configSql);
						if (configList.size() > 0) {
							String order = "";
							String tgtTabId = "";
							String colId1 = "";
							String colId2 = "";
							String colId3 = "";
							String input1 = "";
							String input2 = "";
							String operation = "";
							for (int j = 0; j < configList.size(); j++) {
								order = String.valueOf(configList.get(j)[0]);
								tgtTabId = String.valueOf(configList.get(j)[1]);
								operation = String.valueOf(configList.get(j)[4]);
								if ("1".equals(order)) {
									colId1 = String.valueOf(configList.get(j)[2]);
									input1 = String.valueOf(configList.get(j)[3]);
								} else if ("2".equals(order)) {
									colId2 = String.valueOf(configList.get(j)[2]);
									input2 = String.valueOf(configList.get(j)[3]);
								} else if ("3".equals(order)) {
									colId3 = String.valueOf(configList.get(j)[2]);
								}
							}
							// 根据统计生成配置信息计算值(此处为组卷时计算值没有ajDataId,但算值方法该参数是必须的,所以传入表ID)
							String configValue = "";
							// 直接传入计算值(此处为组卷时计算值没有ajDataId,但算值方法该参数是必须的,所以传入表ID)
							configValue = getValueByconfig(tableId, tgtTabId, colId1, colId2, colId3, input1, input2, operation, colType, orgId, deptId, sysId, tableId, wjIds);
							// 对“null”处理
							if (null == configValue || "null".equals(configValue)) {
								configValue = "";
							}
							// 根据字段类型填值
							if (null != configValue && !"".equals(configValue) && !"null".equals(configValue)) {
								colValue = configValue;
							}
						}
					}
				}
				map.put("COL_VALUE", colValue);
				map.put("COL_VALUE_NAME", colValueName);
				list.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (xlRs != null) {
				try {
					xlRs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return list;
	}

	/**
	 * 根据表ID，获取表的列信息以及数据
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param pageNo
	 *            (如果为空，不进行分页)
	 * @param pageSize
	 *            (如果为空，不进行分页)
	 * @param serachMap
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasByIntfs(String orgId, String deptId, String sysId, String tableId, String pageNo, String pageSize, Map<String, Object> serachMap) throws Exception {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		CbbTables cbbTables = getCbbTablesById(tableId);
		StringBuffer sbSqlData = new StringBuffer();
		sbSqlData.append("SELECT * FROM " + cbbTables.getTableName() + " WHERE 1 = 1");
		Iterator iterator = serachMap.keySet().iterator();
		while (iterator.hasNext()) {
			String colName = String.valueOf(iterator.next());
			String value = String.valueOf(serachMap.get(colName));
			if (!value.equals("")) {
				String colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);// 获取该字段类型
				if ("string".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlData.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
					} else {
						sbSqlData.append(" AND " + colName + "='" + value + "'");
					}
				} else if ("integer".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlData.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
					} else {
						sbSqlData.append(" AND " + colName + "=" + value);
					}
				} else if ("date".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlData.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
					} else {
						sbSqlData.append(" AND " + colName + "= TO_DATE('" + value + "','yyyy-MM-dd')");
					}
				} else if ("float".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlData.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
					} else {
						sbSqlData.append(" AND " + colName + "=" + value);
					}
				} else if ("clob".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlData.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
					} else {
						sbSqlData.append(" AND DBMS_LOB.SUBSTR(" + colName + ",32767) like '%" + value + "%'");
					}
				}
			}
		}
		// 获取排序字段
		List<Map<String, Object>> sortlist = commTableManagerIntfsService.getColDataOrderByTableId(tableId, sysId, orgId, deptId);
		for (int i = 0; i < sortlist.size(); i++) {
			if (i == 0) {
				sbSqlData.append(" ORDER BY ");
			}
			Map<String, Object> sortMap = sortlist.get(i);
			String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
			String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
			// A-升序，D-降序
			if ("A".equals(sortCode)) {
				sortCode = " ASC";
			} else {
				sortCode = " DESC";
			}
			sbSqlData.append(colName + sortCode + ",");
		}
		String sql = "";
		if (sortlist.size() > 0) {
			sql = sbSqlData.substring(0, sbSqlData.length() - 1);
		} else {
			sql = sbSqlData.toString();
		}
		List<CbbTabColumns> formShowList = getFormShowTableList(tableId, "", cbbTables.getTableName(), "0", sysId, orgId, deptId, "");// 基本字段对象

		// add start by zyh 2015.06.15
		List<String> colIds = new ArrayList<String>();
		StringBuffer queryLookupSql = new StringBuffer();
		queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
		queryLookupSql.append(" WHERE T.COLUMN_ID IN (");
		// 获得存在通用代码列的列id
		for (int i = 0; i < formShowList.size(); i++) {
			CbbTabColumns ctcs = formShowList.get(i);
			if ("1".equals(ctcs.getColDropdownType()) || "2".equals(ctcs.getColDropdownType())) {
				queryLookupSql.append("'" + ctcs.getId() + "',");
				colIds.add(ctcs.getId());
			}
		}
		String querySql = "";
		if (queryLookupSql.toString().endsWith(",")) {
			querySql = queryLookupSql.substring(0, queryLookupSql.length() - 1) + ")";
		}
		// 查询出列中所需通用代码
		List<Map<String, Object>> lookupList = new ArrayList<Map<String, Object>>();
		if (colIds.size() > 0) {
			lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(querySql);
		}
		// 创建通用代码map便于赋值
		Map<String, Map<String, String>> lookupMapKeyValue = new HashMap<String, Map<String, String>>();
		for (int i = 0; i < colIds.size(); i++) {
			Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
			for (int j = 0; j < lookupList.size(); j++) {
				Map<String, Object> lookupMap = lookupList.get(j);
				if (colIds.get(i).equals(lookupMap.get("COLUMN_ID"))) {
					lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
				}
			}
			lookupMapKeyValue.put(colIds.get(i), lookupNameCodeMap);
		}
		// add end by zyh 2015.06.15

		// 构造PAGE对象
		String sqlPage = "";
		long count = 0;
		String sqlCount = "select count(1) from (" + sql + ")";
		if (!"".equals(pageSize) && !"".equals(pageNo)) {
			Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
			page.setPageSize(ComUtil.getPageSize(pageSize));
			page.setPageNo(ComUtil.getPageNo(pageNo));
			Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());
			int firstResult = pageBean.getFirstEntityIndex();
			int maxResults = pageBean.getRows();
			if (firstResult <= 0) {
				sqlPage = "select * from ( " + sql + " ) where rownum <= " + maxResults;
			} else {
				sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + sql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
			}
		} else {
			sqlPage = sql;
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			rs = statement.executeQuery(sqlCount);
			while (rs.next()) {
				count = rs.getLong(1);
			}
			rs = statement.executeQuery(sqlPage);
			int num = 0;
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				if (num == 0) {
					map.put("ROW_COUNT", count);
				}
				num++;
				// 循环基本字段进行赋值
				for (int i = 0; i < formShowList.size(); i++) {
					String cValue = "";// 具体的值
					String colName = formShowList.get(i).getColName();// 列名
					String colType = formShowList.get(i).getColType();// 列类型
					String colRuleName = formShowList.get(i).getColRuleName();// 列规则名称
					if ("string".equals(colType)) {
						cValue = rs.getString(colName);
					} else if ("integer".equals(colType)) {
						cValue = rs.getString(colName);
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("date".equals(colType)) {
						cValue = rs.getDate(colName) + "";
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("float".equals(colType)) {
						cValue = rs.getString(colName);
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("clob".equals(colType)) {
						Clob clobInData = rs.getClob(colName);
						if (null != clobInData) {
							int clobLength = (int) clobInData.length();
							cValue = clobInData.getSubString(1, clobLength);
						}
					}
					if ("1".equals(formShowList.get(i).getColDropdownType()) || "2".equals(formShowList.get(i).getColDropdownType())) {
						// StringBuffer sbSql = new StringBuffer();
						// sbSql.append("SELECT T.LOOKUP_NAME\n");
						// sbSql.append("  FROM CBB_TAB_LOOKUP_V T\n");
						// sbSql.append(" WHERE T.COLUMN_ID = '"
						// + formShowList.get(i).getId() + "'\n");
						// sbSql.append("   AND T.LOOKUP_CODE = '" + cValue +
						// "'");
						// List<Object> listValue = hibernateDao.findBySQL(sbSql
						// .toString());
						// String codeName = "";
						// if (listValue.size() != 0) {
						// codeName = String.valueOf(listValue.get(0));//
						// 获取该列该值所对应的通用代码名称
						// } else {
						// codeName = cValue;
						// }
						// map.put(colName, codeName);
						// add start by zyh 2015.06.15
						Map<String, String> showLookupMap = lookupMapKeyValue.get(formShowList.get(i).getId());
						map.put(colName, showLookupMap.get(cValue) == null ? cValue : showLookupMap.get(cValue));
						// map.put(colName + "_CODE", cValue);
						// add end by zyh 2015.06.15
					} else if ("user".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String[] users = cValue.split(",");
							String usersName = "";
							for (int q = 0; q < users.length; q++) {
								if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
									SysUser su = userLoader.getSysUserById(users[q]);
									if (null != su) {
										usersName = usersName + su.getName() + ",";
									} else {
										usersName = usersName + users[q] + ",";
									}
									// usersName = usersName +
									// userLoader.getSysUserById(users[q]).getName()
									// + ",";
								}
							}
							usersName = usersName.substring(0, usersName.length() - 1);
							map.put(colName, usersName);
						}
					} else if ("dept".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String[] depts = cValue.split(",");
							String deptName = "";
							for (int q = 0; q < depts.length; q++) {
								if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
									SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
									if (null != sdt) {
										deptName = deptName + sdt.getDeptName() + ",";
									} else {
										deptName = deptName + depts[q] + ",";
									}
									// deptName = deptName +
									// deptLoader.getSysDeptTl(depts[q],
									// "zh_CN").getDeptName() + ",";
								}
							}
							deptName = deptName.substring(0, deptName.length() - 1);
							map.put(colName, deptName);
						}
					} else if ("custom".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String path = formShowList.get(i).getCustomPath();// 获取自定义页面路径
							// 截取表名，字段值
							if (!"".equals(path) && null != path) {
								String[] url = path.split("[?]");
								if (url.length > 1) {
									String[] arg = url[1].split("&");// 表名，字段值字符串
									if (arg.length > 1) {
										String cNames = "";// 返回的显示值字符串
										String tName = arg[0].split("=")[1];// 表名
										String cName = arg[1].split("=")[1];// 列名
										// JDBC实现
										// 查询列的值，并且给attribute02赋值
										StringBuffer sbSqlCustom = new StringBuffer();
										sbSqlCustom.append("SELECT T." + cName + "\n");
										sbSqlCustom.append("  FROM " + tName + " T\n");
										sbSqlCustom.append(" WHERE T.ID IN (");
										String[] datas = cValue.split(",");
										for (int d = 0; d < datas.length; d++) {
											if (d == datas.length - 1) {
												sbSqlCustom.append("'" + datas[d] + "'\n");
											} else {
												sbSqlCustom.append("'" + datas[d] + "',\n");
											}
										}
										sbSqlCustom.append(")");
										ResultSet rss = null;
										Statement statements = null;
										try {
											statements = conn.createStatement();
											rss = statements.executeQuery(sbSqlCustom.toString());
											while (rss.next()) {
												cNames = cNames + rss.getString(cName) + ",";
											}
											if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
												cNames = cNames.substring(0, cNames.length() - 1);
											}
											map.put(colName, cNames);
										} catch (Exception e) {
											e.printStackTrace();
										} finally {
											if (rss != null) {
												try {
													rss.close();
													rss = null;
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
											if (statements != null) {
												try {
													statements.close();
													statements = null;
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
										}
									}
								}
							}
						}
					} else {
						map.put(colName, cValue);
					}
				}
				map.put("ID", rs.getString("ID"));
				list.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return list;
	}

	/**
	 * 添加业务数据（批量）
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param listMapObj
	 * @param param
	 *            参数map[p1：key='wjIds'，value：String非必填（文件数据ID，组卷新增案卷时时有值）]
	 *            [p2：key='dataId'，value：String非必填（数据ID，顺带时有值）]
	 * @throws Exception
	 * @throws
	 */
	@Override
	public String insertRecordByBatchByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, List<Map<String, Object>> listMapObj, String loginUserId, String loginIp, Map<String, Object> param) throws Exception {
		String wjIds = "";
		String id = "";
		if (null != param && param.containsKey("wjIds")) {
			wjIds = String.valueOf(param.get("wjIds"));
		}
		String dataId = ""; // 顺带的数据ID
		if (null != param && param.containsKey("dataId")) {
			dataId = String.valueOf(param.get("dataId"));
		}
		for (int i = 0; i < listMapObj.size(); i++) {
			// 构造参数集合
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("tableId", tableId);
			params.put("mapObj", listMapObj.get(i));
			params.put("loginUserId", loginUserId);
			params.put("loginIp", loginIp);
			params.put("wjIds", wjIds);
			params.put("dataId", dataId);
			params.put("modleName", param.get("modleName"));
			// 执行添加方法
			id = insertRecordByConfigByIntfs(orgId, deptId, sysId, params);
			listMapObj.get(i).put("ID", id);
		}
		return id;
	}

	/**
	 * 根据表ID，获取字段通用代码数据(不带参数集合)
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param dataId
	 *            (如果查询不带数据的记录，那么该参数为空字符串)
	 * @param flag
	 *            (1-是否添加或编辑显示 2-是否列表显示 3-是否详细显示 4-是否查询显示 0-全部字段显示)
	 * @return
	 * @throws Exception
	 *             Map<String,Map<String,String>>
	 * @throws
	 */
	@Override
	public Map<String, Map<String, String>> getBillLookUpCodeByIntfs(String orgId, String deptId, String sysId, String tableId, String dataId, String flag) throws Exception {
		Map<String, Map<String, String>> mapCode = new HashMap<String, Map<String, String>>();// 返回值
		if ("".equals(dataId)) {
			StringBuffer sql = new StringBuffer();
			sql.append("SELECT T.ID\n");
			sql.append("  FROM CBB_TAB_COLUMNS T\n");
			sql.append(" WHERE (T.COL_DROPDOWN_TYPE = '1' OR T.COL_DROPDOWN_TYPE = '2' OR T.COL_DROPDOWN_TYPE = '4')\n");
			sql.append("   AND T.COL_IS_DISPLAY = 'Y' AND T.TABLE_ID = '" + tableId + "'\n");
			sql.append(" ORDER BY T.COL_ORDER,T.COL_NAME");
			List<Object> colList = hibernateDao.findBySQL(sql.toString());
			// 循环基本字段
			for (int i = 0; i < colList.size(); i++) {
				String cid = String.valueOf(colList.get(i));
				CbbTabColumns cbbTabColumns = new CbbTabColumns();
				cbbTabColumns = getCbbTabColumnsById(cid);
				// 判断该字段是否存在通用代码
				StringBuffer sbSql = new StringBuffer();
				sbSql.append("WITH T1 AS\n");
				sbSql.append(" (SELECT CTCC.LOOKUP_NAME, CTCC.LOOKUP_CODE, CTCC.CODE_ORDER\n");
				sbSql.append("    FROM CBB_TAB_COL_CODE CTCC\n");
				sbSql.append("   WHERE CTCC.COLUMN_ID = '" + cbbTabColumns.getId() + "' AND CTCC.CODE_IS_VALID = 'Y'\n");
				sbSql.append("  UNION\n");
				sbSql.append("  SELECT CLV.LOOKUP_NAME, CLV.LOOKUP_CODE, CLV.CODE_ORDER\n");
				sbSql.append("    FROM CBB_TAB_COL_SYS_CODE CTCSC\n");
				sbSql.append("    LEFT JOIN CBB_LOOKUP_V CLV\n");
				sbSql.append("      ON CLV.ID = CTCSC.SYS_LOOKUP_ID\n");
				sbSql.append("   WHERE CTCSC.COLUMN_ID = '" + cbbTabColumns.getId() + "')\n");
				sbSql.append("SELECT T1.LOOKUP_NAME, T1.LOOKUP_CODE FROM T1 ORDER BY T1.CODE_ORDER");
				List<Object[]> colCodeList = hibernateDao.findBySQL(sbSql.toString());
				Map<String, String> map = new LinkedHashMap<String, String>();
				if (!"KM".equals(sysId)) {
					map.put("", "---请选择---");
				}

				for (int j = 0; j < colCodeList.size(); j++) {
					Object obj[] = colCodeList.get(j);
					String lookupName = String.valueOf(obj[0]);// 显示值
					String lookupCode = String.valueOf(obj[1]);// 真实值
					map.put(lookupCode, lookupName);
				}
				/******
				 * 2015/07/24增加 -
				 * 郭亮（字段配置统计生成时根据配置信息计算后的值不在原通用代码中，将字段的值加到通用代码集合中）
				 *******/
				String colValue = cbbTabColumns.getColValue();
				if ("5".equals(cbbTabColumns.getColGeneMethod())) {
					if (!map.containsKey(colValue)) {
						map.put(colValue, colValue);
					}
				}
				/******
				 * 2015/07/24增加 -
				 * 郭亮（字段配置统计生成时根据配置信息计算后的值不在原通用代码中，将字段的值加到通用代码集合中）
				 *******/
				mapCode.put(cbbTabColumns.getColName(), map);
			}
		} else {
			List<Map<String, Object>> list = getEditOrDetailFieldsAndDataByIntfs(orgId, deptId, sysId, tableId, dataId, flag, new HashMap<String, Object>());
			// 循环基本字段
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> mapCol = list.get(i);
				String cid = String.valueOf(mapCol.get("ID"));
				CbbTabColumns cbbTabColumns = getCbbTabColumnsById(cid);
				// 判断该字段是否存在通用代码
				if ("1".equals(cbbTabColumns.getColDropdownType()) || "2".equals(cbbTabColumns.getColDropdownType())) {
					StringBuffer sbSql = new StringBuffer();
					sbSql.append("WITH T1 AS\n");
					sbSql.append(" (SELECT CTCC.LOOKUP_NAME, CTCC.LOOKUP_CODE, CTCC.CODE_ORDER\n");
					sbSql.append("    FROM CBB_TAB_COL_CODE CTCC\n");
					sbSql.append("   WHERE CTCC.COLUMN_ID = '" + cbbTabColumns.getId() + "' AND CTCC.CODE_IS_VALID = 'Y'\n");
					sbSql.append("  UNION\n");
					sbSql.append("  SELECT CLV.LOOKUP_NAME, CLV.LOOKUP_CODE, CLV.CODE_ORDER\n");
					sbSql.append("    FROM CBB_TAB_COL_SYS_CODE CTCSC\n");
					sbSql.append("    LEFT JOIN CBB_LOOKUP_V CLV\n");
					sbSql.append("      ON CLV.ID = CTCSC.SYS_LOOKUP_ID\n");
					sbSql.append("   WHERE CTCSC.COLUMN_ID = '" + cbbTabColumns.getId() + "')\n");
					sbSql.append("SELECT T1.LOOKUP_NAME, T1.LOOKUP_CODE FROM T1 ORDER BY T1.CODE_ORDER");
					List<Object[]> colCodeList = hibernateDao.findBySQL(sbSql.toString());
					Map<String, String> map = new LinkedHashMap<String, String>();
					if (!"KM".equals(sysId)) {
						map.put("", "---请选择---");
					}
					for (int j = 0; j < colCodeList.size(); j++) {
						Object obj[] = colCodeList.get(j);
						String lookupName = String.valueOf(obj[0]);// 显示值
						String lookupCode = String.valueOf(obj[1]);// 真实值
						map.put(lookupCode, lookupName);
					}
					/******
					 * 2015/07/24增加 -
					 * 郭亮（字段配置统计生成时根据配置信息计算后的值不在原通用代码中，将字段的值加到通用代码集合中）
					 *******/
					String colValue2 = cbbTabColumns.getColValue();
					if ("5".equals(cbbTabColumns.getColGeneMethod())) {
						if (!map.containsKey(colValue2)) {
							map.put(colValue2, colValue2);
						}
					}
					/******
					 * 2015/07/24增加 -
					 * 郭亮（字段配置统计生成时根据配置信息计算后的值不在原通用代码中，将字段的值加到通用代码集合中）
					 *******/
					mapCode.put(cbbTabColumns.getColName(), map);
				}
			}
		}
		return mapCode;
	}

	/**
	 * 根据表ID，获取字段通用代码数据
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param dataId
	 *            (如果查询不带数据的记录，那么该参数为空字符串)
	 * @param flag
	 *            (1-是否添加或编辑显示 2-是否列表显示 3-是否详细显示 4-是否查询显示 0-全部字段显示)
	 * @param params
	 *            (key:userSecretLevel-当前用户密级)
	 * @return
	 * @throws Exception
	 *             Map<String,Map<String,String>>
	 * @throws
	 */
	@Override
	public Map<String, Map<String, String>> getBillLookUpCodeByIntfs(String orgId, String deptId, String sysId, String tableId, String dataId, String flag, Map<String, Object> params) throws Exception {
		Map<String, Map<String, String>> mapCode = new HashMap<String, Map<String, String>>();// 返回值
		boolean isOpenSecret = false;// 是否开启档案目录权限标识
		// 调用rest服务
//		CbbUserAuthSecretRestClient cbbUserAuthSecretRestClient = new CbbUserAuthSecretRestClient("/api/im/lantop/basic/UserAuthSecret");
//		ResponseMsg<String> responseMsg = RestClient.doPost(cbbUserAuthSecretRestClient.getRestUrl("/getSecret/v1"), "", new GenericType<ResponseMsg<String>>() {
//		});
		ResponseMsg<String> responseMsg = RestClient.doPost("/getSecret/v1", "", new GenericType<ResponseMsg<String>>() {
		});
		if (responseMsg.getRetCode().equals(ResponseStatus.HTTP_OK)) {
			String secret = responseMsg.getResponseBody();
			if ("2".equals(secret) || "4".equals(secret)) {
				isOpenSecret = true;
			}
		}
		List<String> secrets = new ArrayList<String>();// 当前人员有权限看到的密集集合
		if (isOpenSecret) {
			String userSecretLevel = String.valueOf(params.get("userSecretLevel"));
			if (null != userSecretLevel && !"null".equals(userSecretLevel) && !"".equals(userSecretLevel)) {
				// 获取文档密级
				Collection<SysLookupSimpleVo> fileSecretList = upLoader.getLookUpListByType("PLATFORM_FILE_SECRET_LEVEL");
				Iterator<SysLookupSimpleVo> iter = fileSecretList.iterator();
				while (iter.hasNext()) {
					SysLookupSimpleVo sysLookupSimpleVo = iter.next();
					boolean isHave = upLoader.isRelation(sysLookupSimpleVo.getLookupCode(), userSecretLevel);
					if (isHave) {
						secrets.add(sysLookupSimpleVo.getLookupCode());
					}
				}
			}
		}
		if ("".equals(dataId)) {
			StringBuffer sql = new StringBuffer();
			sql.append("SELECT T.ID\n");
			sql.append("  FROM CBB_TAB_COLUMNS T\n");
			sql.append(" WHERE (T.COL_DROPDOWN_TYPE = '1' OR T.COL_DROPDOWN_TYPE = '2')\n");
			sql.append("   AND T.COL_IS_DISPLAY = 'Y' AND T.TABLE_ID = '" + tableId + "'\n");
			sql.append(" ORDER BY T.COL_ORDER,T.COL_NAME");
			List<Object> colList = hibernateDao.findBySQL(sql.toString());
			// 循环基本字段
			for (int i = 0; i < colList.size(); i++) {
				String cid = String.valueOf(colList.get(i));
				CbbTabColumns cbbTabColumns = new CbbTabColumns();
				cbbTabColumns = getCbbTabColumnsById(cid);
				// 判断该字段是否存在通用代码
				StringBuffer sbSql = new StringBuffer();
				sbSql.append("WITH T1 AS\n");
				sbSql.append(" (SELECT CTCC.LOOKUP_NAME, CTCC.LOOKUP_CODE, CTCC.CODE_ORDER\n");
				sbSql.append("    FROM CBB_TAB_COL_CODE CTCC\n");
				sbSql.append("   WHERE CTCC.COLUMN_ID = '" + cbbTabColumns.getId() + "' AND CTCC.CODE_IS_VALID = 'Y'\n");
				sbSql.append("  UNION\n");
				sbSql.append("  SELECT CLV.LOOKUP_NAME, CLV.LOOKUP_CODE, CLV.CODE_ORDER\n");
				sbSql.append("    FROM CBB_TAB_COL_SYS_CODE CTCSC\n");
				sbSql.append("    LEFT JOIN CBB_LOOKUP_V CLV\n");
				sbSql.append("      ON CLV.ID = CTCSC.SYS_LOOKUP_ID\n");
				sbSql.append("   WHERE CTCSC.COLUMN_ID = '" + cbbTabColumns.getId() + "')\n");
				sbSql.append("SELECT T1.LOOKUP_NAME, T1.LOOKUP_CODE FROM T1 ORDER BY T1.CODE_ORDER");
				List<Object[]> colCodeList = hibernateDao.findBySQL(sbSql.toString());
				Map<String, String> map = new LinkedHashMap<String, String>();
				map.put("", "---请选择---");
				for (int j = 0; j < colCodeList.size(); j++) {
					Object obj[] = colCodeList.get(j);
					String lookupName = String.valueOf(obj[0]);// 显示值
					String lookupCode = String.valueOf(obj[1]);// 真实值
					if ("SECRET_LEVEL".equals(cbbTabColumns.getColName())) {// 当前登录人进行密级选项过滤
						if (isOpenSecret) {
							if (secrets.contains(lookupCode)) {
								map.put(lookupCode, lookupName);
							}
						} else {
							map.put(lookupCode, lookupName);
						}
					} else {
						map.put(lookupCode, lookupName);
					}
				}
				/******
				 * 2015/07/24增加 -
				 * 郭亮（字段配置统计生成时根据配置信息计算后的值不在原通用代码中，将字段的值加到通用代码集合中）
				 *******/
				String colValue = cbbTabColumns.getColValue();
				if ("5".equals(cbbTabColumns.getColGeneMethod())) {
					if (!map.containsKey(colValue)) {
						map.put(colValue, colValue);
					}
				}
				/******
				 * 2015/07/24增加 -
				 * 郭亮（字段配置统计生成时根据配置信息计算后的值不在原通用代码中，将字段的值加到通用代码集合中）
				 *******/
				mapCode.put(cbbTabColumns.getColName(), map);
			}
		} else {
			List<Map<String, Object>> list = getEditOrDetailFieldsAndDataByIntfs(orgId, deptId, sysId, tableId, dataId, flag, params);
			// 循环基本字段
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> mapCol = list.get(i);
				String cid = String.valueOf(mapCol.get("ID"));
				CbbTabColumns cbbTabColumns = getCbbTabColumnsById(cid);
				// 判断该字段是否存在通用代码
				if ("1".equals(cbbTabColumns.getColDropdownType()) || "2".equals(cbbTabColumns.getColDropdownType())) {
					StringBuffer sbSql = new StringBuffer();
					sbSql.append("WITH T1 AS\n");
					sbSql.append(" (SELECT CTCC.LOOKUP_NAME, CTCC.LOOKUP_CODE, CTCC.CODE_ORDER\n");
					sbSql.append("    FROM CBB_TAB_COL_CODE CTCC\n");
					sbSql.append("   WHERE CTCC.COLUMN_ID = '" + cbbTabColumns.getId() + "' AND CTCC.CODE_IS_VALID = 'Y'\n");
					sbSql.append("  UNION\n");
					sbSql.append("  SELECT CLV.LOOKUP_NAME, CLV.LOOKUP_CODE, CLV.CODE_ORDER\n");
					sbSql.append("    FROM CBB_TAB_COL_SYS_CODE CTCSC\n");
					sbSql.append("    LEFT JOIN CBB_LOOKUP_V CLV\n");
					sbSql.append("      ON CLV.ID = CTCSC.SYS_LOOKUP_ID\n");
					sbSql.append("   WHERE CTCSC.COLUMN_ID = '" + cbbTabColumns.getId() + "')\n");
					sbSql.append("SELECT T1.LOOKUP_NAME, T1.LOOKUP_CODE FROM T1 ORDER BY T1.CODE_ORDER");
					List<Object[]> colCodeList = hibernateDao.findBySQL(sbSql.toString());
					Map<String, String> map = new LinkedHashMap<String, String>();
					map.put("", "---请选择---");
					for (int j = 0; j < colCodeList.size(); j++) {
						Object obj[] = colCodeList.get(j);
						String lookupName = String.valueOf(obj[0]);// 显示值
						String lookupCode = String.valueOf(obj[1]);// 真实值
						if ("SECRET_LEVEL".equals(cbbTabColumns.getColName())) {// 当前登录人进行密级选项过滤
							if (isOpenSecret) {
								if (secrets.contains(lookupCode)) {
									map.put(lookupCode, lookupName);
								}
							} else {
								map.put(lookupCode, lookupName);
							}
						} else {
							map.put(lookupCode, lookupName);
						}
					}
					/******
					 * 2015/07/24增加 -
					 * 郭亮（字段配置统计生成时根据配置信息计算后的值不在原通用代码中，将字段的值加到通用代码集合中）
					 *******/
					String colValue2 = cbbTabColumns.getColValue();
					if ("5".equals(cbbTabColumns.getColGeneMethod())) {
						if (!map.containsKey(colValue2)) {
							map.put(colValue2, colValue2);
						}
					}
					/******
					 * 2015/07/24增加 -
					 * 郭亮（字段配置统计生成时根据配置信息计算后的值不在原通用代码中，将字段的值加到通用代码集合中）
					 *******/
					mapCode.put(cbbTabColumns.getColName(), map);
				}
			}
		}
		return mapCode;
	}

	/**
	 * 根据表ID，获取所有选择弹出框信息（返回值以英文分号隔开）
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @return
	 * @throws Exception
	 *             String
	 * @throws
	 */
	@Override
	public String getSelectDialogStringByIntfs(String orgId, String deptId, String sysId, String tableId) throws Exception {
		String userDpetString = "";
		String sql = "SELECT T.ID FROM CBB_TAB_COLUMNS T WHERE T.COL_IS_DISPLAY = 'Y' AND T.TABLE_ID ='" + tableId + "' ORDER BY T.COL_ORDER,T.COL_NAME";
		List<Object> colList = hibernateDao.findBySQL(sql);
		// 循环基本字段
		for (int i = 0; i < colList.size(); i++) {
			String cid = String.valueOf(colList.get(i));
			CbbTabColumns cbbTabColumns = new CbbTabColumns();
			cbbTabColumns = getCbbTabColumnsById(cid);
			String colRuleName = cbbTabColumns.getColRuleName();
			String colName = cbbTabColumns.getColName();
			if ("user".equals(colRuleName)) {
				userDpetString = userDpetString + "user," + colName + "NAME," + colName + ",选择用户;";
			} else if ("dept".equals(colRuleName)) {
				userDpetString = userDpetString + "dept," + colName + "NAME," + colName + ",选择部门;";
			}
		}
		return userDpetString;
	}

	/**
	 * 根据表ID，获取公共表中所有选择弹出框信息（返回值以英文分号隔开）
	 * @author 郭亮
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @return
	 * @throws Exception String
	 */
	@Override
	public String getSelectDialogStringByPubByIntfs(String orgId, String deptId, String sysId, String tableId) throws Exception {
		String userDpetString = "";
		String sql = "SELECT T.ID FROM CBB_TAB_COLUMNS T WHERE T.COL_IS_DISPLAY = 'Y' AND T.TABLE_ID ='" + tableId + "' ORDER BY T.COL_ORDER,T.COL_NAME";
		List<Object> colList = hibernateDao.findBySQL(sql);
		// 循环基本字段
		for (int i = 0; i < colList.size(); i++) {
			String cid = String.valueOf(colList.get(i));
			CbbTabColumns cbbTabColumns = new CbbTabColumns();
			cbbTabColumns = getCbbTabColumnsById(cid);
			String colRuleName = cbbTabColumns.getColRuleName();
			String colName = cbbTabColumns.getColName();
			String colDropdownType = cbbTabColumns.getColDropdownType();
			if ("3".equals(colDropdownType)) {
				if ("user".equals(colRuleName)) {
					userDpetString = userDpetString + "user," + colName + "_ID," + colName + ",选择用户;";
				} else if ("dept".equals(colRuleName)) {
					userDpetString = userDpetString + "dept," + colName + "_ID," + colName + ",选择部门;";
				}
			}
		}
		return userDpetString;
	}

	/**
	 * 根据表ID和列名称获取列类型
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param colName
	 * @return
	 * @throws Exception
	 *             String
	 * @throws
	 */
	@Override
	public String getColTypeByTableIdAndColNameByIntfs(String orgId, String deptId, String sysId, String tableId, String colName) {
		String type = "";
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT CTC.COL_TYPE\n");
		sbSql.append("  FROM CBB_TAB_COLUMNS CTC\n");
		sbSql.append(" WHERE CTC.TABLE_ID = '" + tableId + "'\n");
		sbSql.append("   AND CTC.COL_NAME = '" + colName + "'\n");
		List<Object> listType = hibernateDao.findBySQL(sbSql.toString());
		if (listType.size() != 0) {
			type = String.valueOf(listType.get(0));
		}
		return type;
	}

	private static final Logger logger = LoggerFactory.getLogger(avicit.cbb.techclass.billdefine.service.impl.BillDefineManagerIntfsServiceImpl.class);
	/**
	 * 根据表ID以及查询条件，获取表的列信息以及数据
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param pageNo
	 * @param pageSize
	 * @param serachCondition
	 * @param param
	 *            (p1:[key:searchOrder
	 *            value:LinkedHashMap<String(字段英文名),String(排序策略：{ASC,DESC}>])
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasBySearchByOrderbyByIntfs(String orgId, String deptId, String sysId, String tableId, String pageNo, String pageSize, String serachCondition, Map<String, Object> param) throws Exception {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

		String sql = "";
		CbbTables cbbTables = getCbbTablesById(tableId);
		// 获取条目是否存在附件状态
		if (null != param && param.containsKey("ATTACH_STATUS") && null != param.get("ATTACH_STATUS") && !"".equals(param.get("ATTACH_STATUS")) && ("1".equals(param.get("ATTACH_STATUS")) || "2".equals(param.get("ATTACH_STATUS")))) {
			sql = "SELECT * FROM (SELECT (SELECT COUNT(1) FROM CBB_DOC_RELATION CDR WHERE CDR.RECORD_ID = T.ID AND CDR.IF_DELETE = 'N') ATTACH_COUNT, T.* FROM " + cbbTables.getTableName() + " T WHERE 1=1 ";
		} else {
			sql = "SELECT * FROM " + cbbTables.getTableName() + " WHERE 1=1 ";
		}
		if (!"".equals(serachCondition)) {
			sql = sql + serachCondition + "  ";
		}
		// 获取排序字段
		// 排序条件
		String sortColName = (String)param.get("sortColName");
		String sortDirection = (String)param.get("sortDirection");
		if (null != sortColName && null != sortDirection && !"".equals(sortColName) && !"".equals(sortDirection) && !"null".equals(sortColName) && !"null".equals(sortDirection)) {
			if ("BROWSE_NUM".equals(sortColName)) {
				// 浏览次数排序
				sql = sql +" ORDER BY " + sortColName + " DESC,";
			} else if ("RQ".equals(sortColName)) {
				// 时间排序
				if ("1".equals(sortDirection)) {
					sql = sql +" ORDER BY RQ ASC,";
				} else {
					sql = sql +" ORDER BY RQ DESC,";
				}
			} else {
				// 相关度

			}
		}


		//自定义排序标识
		if(null != param && param.containsKey("customSorting")){
		if (null != param && param.containsKey("searchOrder")) {
			LinkedHashMap<String, String> orderMap = (LinkedHashMap<String, String>) param.get("searchOrder");
			if (orderMap.size() > 0) {
				// 取自定义排序
				int orderIndex = 0;
				Iterator orderIt = orderMap.keySet().iterator();
				while (orderIt.hasNext()) {
					String orderCol = String.valueOf(orderIt.next());// 排序字段英文名
					String orderRule = orderMap.get(orderCol);// 排序规则
					if (null != orderCol && !"".equals(orderCol) && !"null".equals(orderCol) && ("ASC".equals(orderRule) || "DESC".equals(orderRule))) {
						if (orderIndex == 0) {
							sql = sql + " ORDER BY " + orderCol + " " + orderRule + ",";
						} else {
							sql = sql + orderCol + " " + orderRule + ",";
						}
						orderIndex++;
					}
				}
			} else {
				//sql=sql+"ORDER BY RQ DESC NULLS LAST ";
			}
		} else {
			// 默认取库结构配置排序
			List<Map<String, Object>> sortlist = commTableManagerIntfsService.getColDataOrderByTableId(tableId, sysId, orgId, deptId);
			for (int i = 0; i < sortlist.size(); i++) {
				if (i == 0) {
					sql = sql + " ORDER BY ";
				}
				Map<String, Object> sortMap = sortlist.get(i);
				String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
				String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
																			// A-升序，D-降序
				if ("A".equals(sortCode)) {
					sortCode = " ASC";
				} else {
					sortCode = " DESC";
				}
				sql = sql + colName + sortCode + ",";
			}
		}
		}
		sql = sql.substring(0, sql.length() - 1);
		List<CbbTabColumns> formShowList = getFormShowTableList(tableId, "", cbbTables.getTableName(), "0", sysId, orgId, deptId, "");// 全部字段对象

		// add start by zyh 2015.06.15
		List<String> colIds = new ArrayList<String>();
		StringBuffer queryLookupSql = new StringBuffer();
		queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
		queryLookupSql.append(" WHERE T.COLUMN_ID IN (");
		// 获得存在通用代码列的列id
		for (int i = 0; i < formShowList.size(); i++) {
			CbbTabColumns ctcs = formShowList.get(i);
			if ("1".equals(ctcs.getColDropdownType()) || "2".equals(ctcs.getColDropdownType())) {
				queryLookupSql.append("'" + ctcs.getId() + "',");
				colIds.add(ctcs.getId());
			}
		}
		String querySql = "";
		if (queryLookupSql.toString().endsWith(",")) {
			querySql = queryLookupSql.substring(0, queryLookupSql.length() - 1) + ")";
		}
		// 查询出列中所需通用代码
		List<Map<String, Object>> lookupList = new ArrayList<Map<String, Object>>();
		if (colIds.size() > 0) {
			lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(querySql);
		}
		// 创建通用代码map便于赋值
		Map<String, Map<String, String>> lookupMapKeyValue = new HashMap<String, Map<String, String>>();
		for (int i = 0; i < colIds.size(); i++) {
			Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
			for (int j = 0; j < lookupList.size(); j++) {
				Map<String, Object> lookupMap = lookupList.get(j);
				if (colIds.get(i).equals(lookupMap.get("COLUMN_ID"))) {
					lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
				}
			}
			lookupMapKeyValue.put(colIds.get(i), lookupNameCodeMap);
		}
		// add end by zyh 2015.06.15
		if (null != param && param.containsKey("ATTACH_STATUS") && null != param.get("ATTACH_STATUS") && !"".equals(param.get("ATTACH_STATUS"))) {
			if ("1".equals(param.get("ATTACH_STATUS"))) {
				sql += ") WHERE ATTACH_COUNT > 0";
			} else if ("2".equals(param.get("ATTACH_STATUS"))) {
				sql += ") WHERE ATTACH_COUNT < 1";
			}
		}

		// 构造PAGE对象
		String sqlPage = "";
		String sqlCount = "select count(1) AS TOTAL from (" + sql + ")";
		List<Map<String, Object>> listTotal = jdbcAvicit.queryForMap(sqlCount, null);// 总数量
		long count = 0;
		if (!"".equals(pageNo) && !"".equals(pageSize) && !"0".equals(pageNo) && !"0".equals(pageSize)) {
			Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
			page.setPageSize(ComUtil.getPageSize(pageSize));
			page.setPageNo(ComUtil.getPageNo(pageNo));
			Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());
			int firstResult = pageBean.getFirstEntityIndex();
			int maxResults = pageBean.getRows();
			if (firstResult <= 0) {
				sqlPage = "select * from ( " + sql + " ) where rownum <= " + maxResults;
			} else {
				sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + sql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
			}
		} else {
			sqlPage = sql;
		}
		logger.info("列表SQL："+sqlPage);
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接

			statement = conn.createStatement();
			rs = statement.executeQuery(sqlCount);
			while (rs.next()) {
				count = rs.getLong(1);
			}
			rs = statement.executeQuery(sqlPage);
			int num = 0;
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				String id = rs.getString("ID");
				if (num == 0) {
					map.put("ROW_COUNT", count);
				}
				num++;
				map.put("serialNumber", num);
				// 循环基本字段进行赋值
				for (int i = 0; i < formShowList.size(); i++) {
					String cValue = "";// 具体的值
					String colName = formShowList.get(i).getColName();// 列名

					String colType = formShowList.get(i).getColType();// 列类型
					String colRuleName = formShowList.get(i).getColRuleName();// 列规则名称
					if ("string".equals(colType)) {
						cValue = rs.getString(colName);
					} else if ("integer".equals(colType)) {
						cValue = rs.getString(colName);
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("date".equals(colType)) {
                        Timestamp timestamp = rs.getTimestamp(colName);
                        if(timestamp==null){
                            cValue="";
                        }else {
//                            Date time1=new Date(timestamp.getTime());
                            SimpleDateFormat formattime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            cValue=formattime.format(timestamp.getTime());
                        }
					} else if ("float".equals(colType)) {
						cValue = rs.getString(colName);
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("clob".equals(colType)) {
						Clob clobInData = rs.getClob(colName);
						if (null != clobInData) {
							int clobLength = (int) clobInData.length();
							cValue = clobInData.getSubString(1, clobLength);
						}
					}

					/*if ("JS".equals(colName)){
						String tableName = cbbTables.getTableName(); //案卷级表名
						String substring = tableName.substring(0, tableName.length() - 3);//文件级表名
						long l = jdbcAvicit.getJdbcTemplate().queryForLong("select count(*) from user_tables where table_name =upper('" + substring + "WJJ')");
						if (l > 0){
							long countJS = jdbcAvicit.getJdbcTemplate().queryForLong("SELECT count(1) FROM "+substring+"WJJ WHERE 1 = 1 AND PARENT_ID = '"+id+"' ");
							cValue=countJS+"";

							//SanXiaFiles update by huangjian start案卷级件数字段 = 文件级总数
							StringBuffer updateAnJsSql = new StringBuffer("");
							updateAnJsSql.append("UPDATE \n");
							updateAnJsSql.append(tableName+" T\n");
							updateAnJsSql.append(" SET T.JS = "+countJS);
							updateAnJsSql.append(" WHERE T.ID = '"+id+"' ");
							try {
								jdbcAvicit.getJdbcTemplate().execute(updateAnJsSql.toString());
							} catch (DataAccessException e) {

							}
							//SanXiaFiles update by huangjian end
						}
					}*/

					if ("1".equals(formShowList.get(i).getColDropdownType()) || "2".equals(formShowList.get(i).getColDropdownType())) {

						// add start by zyh 2015.06.15
						Map<String, String> showLookupMap = lookupMapKeyValue.get(formShowList.get(i).getId());
						map.put(colName, showLookupMap.get(cValue) == null ? cValue : showLookupMap.get(cValue));
						map.put(colName + "_CODE", cValue);
						// add end by zyh 2015.06.15
					} else if ("user".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String[] users = cValue.split(",");
							String usersName = "";
							String userId = "";
							for (int q = 0; q < users.length; q++) {
								if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
									SysUser su = userLoader.getSysUserById(users[q]);
									if (null != su) {
										usersName = usersName + su.getName() + ",";
										userId = userId + users[q] + ",";
									} else {
										usersName = usersName + users[q] + ",";
										userId = userId + users[q] + ",";
									}
								}
							}
							usersName = usersName.substring(0, usersName.length() - 1);
							userId = userId.substring(0, userId.length() - 1);
							map.put(colName, usersName);
							map.put(colName + "_CODE", userId);
						}
					} else if ("dept".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String[] depts = cValue.split(",");
							String deptName = "";
							String deptIds = "";
							for (int q = 0; q < depts.length; q++) {
								if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
									SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
									if (null != sdt) {
										deptName = deptName + sdt.getDeptName() + ",";
										deptIds = deptIds + depts[q] + ",";
									} else {
										deptName = deptName + depts[q] + ",";
										deptIds = deptIds + depts[q] + ",";
									}
								}
							}
							deptName = deptName.substring(0, deptName.length() - 1);
							deptIds = deptIds.substring(0, deptIds.length() - 1);
							map.put(colName, deptName);
							map.put(colName + "_CODE", deptIds);
						}
					} else if ("custom".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String path = formShowList.get(i).getCustomPath();// 获取自定义页面路径
							// 截取表名，字段值
							if (!"".equals(path) && null != path) {
								String[] url = path.split("[?]");
								if (url.length > 1) {
									String[] arg = url[1].split("&");// 表名，字段值字符串
									if (arg.length > 1) {
										String cNames = "";// 返回的显示值字符串
										String tName = arg[0].split("=")[1];// 表名
										String cName = arg[1].split("=")[1];// 列名
										StringBuffer sbSqlCustom = new StringBuffer();
										sbSqlCustom.append("SELECT T." + cName + "\n");
										sbSqlCustom.append("  FROM " + tName + " T\n");
										sbSqlCustom.append(" WHERE T.ID IN (");
										String[] datas = cValue.split(",");
										for (int d = 0; d < datas.length; d++) {
											if (d == datas.length - 1) {
												sbSqlCustom.append("'" + datas[d] + "'\n");
											} else {
												sbSqlCustom.append("'" + datas[d] + "',\n");
											}
										}
										sbSqlCustom.append(")");
										// JDBC实现
										// 查询列的值，并且给attribute02赋值
										Statement statements = null;
										ResultSet rss = null;
										try {
											statements = conn.createStatement();
											rss = statements.executeQuery(sbSqlCustom.toString());
											while (rss.next()) {
												cNames = cNames + rss.getString(cName) + ",";
											}
											if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
												cNames = cNames.substring(0, cNames.length() - 1);
											}
											map.put(colName, cNames);
										} catch (Exception e) {
											e.printStackTrace();
											throw new Exception("数据库操作异常，请联系管理员！");
										} finally {
											if (rss != null) {
												try {
													rss.close();
													rss = null;
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
											if (statements != null) {
												try {
													statements.close();
													statements = null;
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
										}
									}
								}
							}
						}
					} else {
						map.put(colName, cValue);
					}
				}
				map.put("ID", rs.getString("ID"));
				map.put("LANTOP_FJ_RCD_ID", rs.getString("ID"));
				list.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					// conn.close();
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		/*if (null != commTableSysFieldLoader.getAttachmentClassName() && !"".equals(commTableSysFieldLoader.getAttachmentClassName())) {
			this.fileUploadIntfsService.getAttachClassification(list);
		}*/
		resultMap.put("ztResultTotal", String.valueOf(listTotal.get(0).get("TOTAL")));// 返回主体查询总数量
		resultMap.put("ztResult", list);
		return list;
	}

	/**
	 * 根据表ID以及查询条件，获取表的列信息以及数据(不自动排序，自己条件排序)
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param pageNo
	 * @param pageNo
	 * @param serachCondition
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasBySearchByIntfs(String orgId, String deptId, String sysId, String tableId, String pageNo, String pageSize, String serachCondition) throws Exception {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		CbbTables cbbTables = getCbbTablesById(tableId);
		String sql = "SELECT * FROM " + cbbTables.getTableName() + " WHERE 1=1 ";
		if (!"".equals(serachCondition)) {
			sql = sql + serachCondition;
		}
		List<CbbTabColumns> formShowList = getFormShowTableList(tableId, "", cbbTables.getTableName(), "0", sysId, orgId, deptId, "");// 全部字段对象

		// add start by zyh 2015.06.15
		List<String> colIds = new ArrayList<String>();
		StringBuffer queryLookupSql = new StringBuffer();
		queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
		queryLookupSql.append(" WHERE T.COLUMN_ID IN (");
		// 获得存在通用代码列的列id
		for (int i = 0; i < formShowList.size(); i++) {
			CbbTabColumns ctcs = formShowList.get(i);
			if ("1".equals(ctcs.getColDropdownType()) || "2".equals(ctcs.getColDropdownType())) {
				queryLookupSql.append("'" + ctcs.getId() + "',");
				colIds.add(ctcs.getId());
			}
		}
		String querySql = "";
		if (queryLookupSql.toString().endsWith(",")) {
			querySql = queryLookupSql.substring(0, queryLookupSql.length() - 1) + ")";
		}
		// 查询出列中所需通用代码
		List<Map<String, Object>> lookupList = new ArrayList<Map<String, Object>>();
		if (colIds.size() > 0) {
			lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(querySql);
		}
		// 创建通用代码map便于赋值
		Map<String, Map<String, String>> lookupMapKeyValue = new HashMap<String, Map<String, String>>();
		for (int i = 0; i < colIds.size(); i++) {
			Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
			for (int j = 0; j < lookupList.size(); j++) {
				Map<String, Object> lookupMap = lookupList.get(j);
				if (colIds.get(i).equals(lookupMap.get("COLUMN_ID"))) {
					lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
				}
			}
			lookupMapKeyValue.put(colIds.get(i), lookupNameCodeMap);
		}
		// add end by zyh 2015.06.15

		// 构造PAGE对象
		String sqlPage = "";
		Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
		page.setPageSize(ComUtil.getPageSize(pageSize));
		page.setPageNo(ComUtil.getPageNo(pageNo));
		Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());
		String sqlCount = "select count(1) from (" + sql + ")";
		long count = 0;
		int firstResult = pageBean.getFirstEntityIndex();
		int maxResults = pageBean.getRows();
		if (firstResult <= 0) {
			sqlPage = "select * from ( " + sql + " ) where rownum <= " + maxResults;
		} else {
			sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + sql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			rs = statement.executeQuery(sqlCount);
			while (rs.next()) {
				count = rs.getLong(1);
			}
			rs = statement.executeQuery(sqlPage);
			int num = 0;
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				if (num == 0) {
					map.put("ROW_COUNT", count);
				}
				num++;
				// 循环基本字段进行赋值
				for (int i = 0; i < formShowList.size(); i++) {
					String cValue = "";// 具体的值
					String colName = formShowList.get(i).getColName();// 列名
					String colType = formShowList.get(i).getColType();// 列类型
					String colRuleName = formShowList.get(i).getColRuleName();// 列规则名称
					if ("string".equals(colType)) {
						cValue = rs.getString(colName);
					} else if ("integer".equals(colType)) {
						cValue = rs.getString(colName);
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("date".equals(colType)) {
						cValue = rs.getDate(colName) + "";
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("float".equals(colType)) {
						cValue = rs.getString(colName);
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("clob".equals(colType)) {
						Clob clobInData = rs.getClob(colName);
						if (null != clobInData) {
							int clobLength = (int) clobInData.length();
							cValue = clobInData.getSubString(1, clobLength);
						}
					}
					if ("1".equals(formShowList.get(i).getColDropdownType()) || "2".equals(formShowList.get(i).getColDropdownType())) {
						// StringBuffer sbSql = new StringBuffer();
						// sbSql.append("SELECT T.LOOKUP_NAME\n");
						// sbSql.append("  FROM CBB_TAB_LOOKUP_V T\n");
						// sbSql.append(" WHERE T.COLUMN_ID = '"
						// + formShowList.get(i).getId() + "'\n");
						// sbSql.append("   AND T.LOOKUP_CODE = '" + cValue +
						// "'");
						// List<Object> listValue = hibernateDao.findBySQL(sbSql
						// .toString());
						// String codeName = "";
						// String codeCode = "";
						// if (listValue.size() != 0) {
						// codeName = String.valueOf(listValue.get(0));//
						// 获取该列该值所对应的通用代码名称
						// } else {
						// codeName = cValue;
						// }
						// codeCode = cValue;
						// map.put(colName, codeName);
						// map.put(colName + "_CODE", codeCode);

						// add start by zyh 2015.06.15
						Map<String, String> showLookupMap = lookupMapKeyValue.get(formShowList.get(i).getId());
						map.put(colName, showLookupMap.get(cValue) == null ? cValue : showLookupMap.get(cValue));
						map.put(colName + "_CODE", cValue);
						// add end by zyh 2015.06.15
					} else if ("user".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String[] users = cValue.split(",");
							String usersName = "";
							String userId = "";
							for (int q = 0; q < users.length; q++) {
								if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
									SysUser su = userLoader.getSysUserById(users[q]);
									if (null != su) {
										usersName = usersName + su.getName() + ",";
										userId = userId + users[q] + ",";
									} else {
										usersName = usersName + users[q] + ",";
										userId = userId + users[q] + ",";
									}
									// usersName = usersName
									// + userLoader.getSysUserById(
									// users[q]).getName() + ",";
									// userId = userId + users[q] + ",";
								}
							}
							usersName = usersName.substring(0, usersName.length() - 1);
							userId = userId.substring(0, userId.length() - 1);
							map.put(colName, usersName);
							map.put(colName + "_CODE", userId);
						}
					} else if ("dept".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String[] depts = cValue.split(",");
							String deptName = "";
							String deptIds = "";
							for (int q = 0; q < depts.length; q++) {
								if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
									SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
									if (null != sdt) {
										deptName = deptName + sdt.getDeptName() + ",";
										deptIds = deptIds + depts[q] + ",";
									} else {
										deptName = deptName + depts[q] + ",";
										deptIds = deptIds + depts[q] + ",";
									}
									// deptName = deptName +
									// deptLoader.getSysDeptTl(depts[q],
									// "zh_CN").getDeptName() + ",";
									// deptIds = deptIds + depts[q] + ",";
								}
							}
							deptName = deptName.substring(0, deptName.length() - 1);
							deptIds = deptIds.substring(0, deptIds.length() - 1);
							map.put(colName, deptName);
							map.put(colName + "_CODE", deptIds);
						}
					} else if ("custom".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String path = formShowList.get(i).getCustomPath();// 获取自定义页面路径
							// 截取表名，字段值
							if (!"".equals(path) && null != path) {
								String[] url = path.split("[?]");
								if (url.length > 1) {
									String[] arg = url[1].split("&");// 表名，字段值字符串
									if (arg.length > 1) {
										String cNames = "";// 返回的显示值字符串
										String tName = arg[0].split("=")[1];// 表名
										String cName = arg[1].split("=")[1];// 列名
										StringBuffer sbSqlCustom = new StringBuffer();
										sbSqlCustom.append("SELECT T." + cName + "\n");
										sbSqlCustom.append("  FROM " + tName + " T\n");
										sbSqlCustom.append(" WHERE T.ID IN (");
										String[] datas = cValue.split(",");
										for (int d = 0; d < datas.length; d++) {
											if (d == datas.length - 1) {
												sbSqlCustom.append("'" + datas[d] + "'\n");
											} else {
												sbSqlCustom.append("'" + datas[d] + "',\n");
											}
										}
										sbSqlCustom.append(")");
										// JDBC实现
										// 查询列的值，并且给attribute02赋值
										Statement statements = null;
										ResultSet rss = null;
										try {
											statements = conn.createStatement();
											rss = statements.executeQuery(sbSqlCustom.toString());
											while (rss.next()) {
												cNames = cNames + rss.getString(cName) + ",";
											}
											if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
												cNames = cNames.substring(0, cNames.length() - 1);
											}
											map.put(colName, cNames);
										} catch (Exception e) {
											e.printStackTrace();
											throw new Exception("数据库操作异常，请联系管理员！");
										} finally {
											if (rss != null) {
												try {
													rss.close();
													rss = null;
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
											if (statements != null) {
												try {
													statements.close();
													statements = null;
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
										}
									}
								}
							}
						}
					} else {
						map.put(colName, cValue);
					}
				}
				map.put("ID", rs.getString("ID"));
				list.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return list;
	}

	/**
	 * 根据表IDS(以英文分号分开,顺序为：父;子)及查询条件， 获取2层表结构（父-子）的列信息以及数据
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param pageNo
	 * @param pageSize
	 * @param serachMap
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasByTwoTablesByIntfs(String orgId, String deptId, String sysId, String tableIds, String pageNo, String pageSize, Map<String, Object> serachMapFroT1, Map<String, Object> serachMapFroT2) throws Exception {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		List<CbbTabColumns> formShowList = new ArrayList<CbbTabColumns>();
		String[] ids = tableIds.split(";");
		String tableId1 = ids[0];
		String tableId2 = ids[1];
		StringBuffer sb = new StringBuffer();
		if (ids.length != 0) {
			CbbTables cbbTablesT1 = getCbbTablesById(tableId1);
			CbbTables cbbTablesT2 = getCbbTablesById(tableId2);
			sb.append("SELECT ");
			// 封装字段信息 T1
			List<CbbTabColumns> formtListT1 = getFormShowTableList(tableId1, "", cbbTablesT1.getTableName(), "0", sysId, orgId, deptId, "");// 基本字段对象
			String tableName1 = cbbTablesT1.getTableName();
			String tableName2 = cbbTablesT2.getTableName();
			for (int j = 0; j < formtListT1.size(); j++) {
				CbbTabColumns cbbTabColumns = formtListT1.get(j);
				String colName = cbbTabColumns.getColName();
				String colAsName = "T1_" + colName;
				if (j == 0) {
					sb.append(" T1.");
					sb.append(colName);
					sb.append(" AS ");
					sb.append(colAsName);
					cbbTabColumns.setColName(colAsName);
					formShowList.add(cbbTabColumns);
				} else {
					sb.append(" ,T1.");
					sb.append(colName);
					sb.append(" AS ");
					sb.append(colAsName);
					cbbTabColumns.setColName(colAsName);
					formShowList.add(cbbTabColumns);
				}
			}
			sb.append("T1.ID AS T1_ID,");
			// 封装字段信息 T2
			List<CbbTabColumns> formtListT2 = getFormShowTableList(tableId2, "", cbbTablesT2.getTableName(), "0", sysId, orgId, deptId, "");// 基本字段对象
			for (int j = 0; j < formtListT2.size(); j++) {
				CbbTabColumns cbbTabColumns = formtListT2.get(j);
				String colName = cbbTabColumns.getColName();
				String colAsName = "T2_" + colName;
				if (formtListT1.size() != 0) {
					sb.append(" ,T2.");
					sb.append(colName);
					sb.append(" AS ");
					sb.append(colAsName);
					cbbTabColumns.setColName(colAsName);
					formShowList.add(cbbTabColumns);
				} else {
					if (j == 0) {
						sb.append(" T2.");
						sb.append(colName);
						sb.append(" AS ");
						sb.append(colAsName);
						cbbTabColumns.setColName(colAsName);
						formShowList.add(cbbTabColumns);
					} else {
						sb.append(" ,T2.");
						sb.append(colName);
						sb.append(" AS ");
						sb.append(colAsName);
						cbbTabColumns.setColName(colAsName);
						formShowList.add(cbbTabColumns);
					}
				}
			}
			sb.append(" FROM " + tableName1);
			sb.append(" T1 LEFT JOIN ");
			sb.append(tableName2);
			sb.append(" T2 ON T2.PARENT_ID = T1.ID WHERE 1=1");
			// 循环条件1
			Iterator iteratorT1 = serachMapFroT1.keySet().iterator();
			while (iteratorT1.hasNext()) {
				String colName = String.valueOf(iteratorT1.next());
				String value = String.valueOf(serachMapFroT1.get(colName));
				if (!value.equals("")) {
					String colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId1, colName);// 获取该字段类型
					if ("string".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "='" + value + "'");
						}
					} else if ("integer".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "=" + value);
						}
					} else if ("date".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "= TO_DATE('" + value + "','yyyy-MM-dd')");
						}
					} else if ("float".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "=" + value);
						}
					} else if ("clob".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND DBMS_LOB.SUBSTR(" + colName + ",32767) like '%" + value + "%'");
						}
					}
				}
			}
			// 循环条件2
			Iterator iteratorT2 = serachMapFroT2.keySet().iterator();
			while (iteratorT2.hasNext()) {
				String colName = String.valueOf(iteratorT2.next());
				String value = String.valueOf(serachMapFroT2.get(colName));
				if (!value.equals("")) {
					String colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId2, colName);// 获取该字段类型
					if ("string".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "='" + value + "'");
						}
					} else if ("integer".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "=" + value);
						}
					} else if ("date".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "= TO_DATE('" + value + "','yyyy-MM-dd')");
						}
					} else if ("float".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "=" + value);
						}
					} else if ("clob".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND DBMS_LOB.SUBSTR(" + colName + ",32767) like '%" + value + "%'");
						}
					}
				}
			}
			// T1表获取排序字段
			List<Map<String, Object>> sortlist1 = commTableManagerIntfsService.getColDataOrderByTableId(tableId1, sysId, orgId, deptId);
			for (int i = 0; i < sortlist1.size(); i++) {
				if (i == 0) {
					sb.append(" ORDER BY ");
				}
				Map<String, Object> sortMap = new HashMap<String, Object>();
				sortMap = sortlist1.get(i);
				String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
				String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
				// A-升序，D-降序
				if ("A".equals(sortCode)) {
					sortCode = " ASC";
				} else {
					sortCode = " DESC";
				}
				sb.append("T1_" + colName + sortCode + ",");
			}
			// T2表获取排序字段
			List<Map<String, Object>> sortlist2 = commTableManagerIntfsService.getColDataOrderByTableId(tableId2, sysId, orgId, deptId);
			for (int i = 0; i < sortlist2.size(); i++) {
				if (i == 0 && sortlist2.size() == 0) {
					sb.append(" ORDER BY ");
				}
				Map<String, Object> sortMap = new HashMap<String, Object>();
				sortMap = sortlist2.get(i);
				String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
				String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
				// A-升序，D-降序
				if ("A".equals(sortCode)) {
					sortCode = " ASC";
				} else {
					sortCode = " DESC";
				}
				sb.append("T2_" + colName + sortCode + ",");
			}
			String allSql = "";
			if (sortlist1.size() != 0 || sortlist2.size() != 0) {
				allSql = sb.substring(0, sb.length() - 1);
			} else {
				allSql = sb.toString();
			}
			// 构造PAGE对象
			String sqlPage = "";
			Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
			page.setPageSize(ComUtil.getPageSize(pageSize));
			page.setPageNo(ComUtil.getPageNo(pageNo));
			Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());
			String sqlCount = "select count(1) from (" + allSql + ")";
			long count = 0;
			int firstResult = pageBean.getFirstEntityIndex();
			int maxResults = pageBean.getRows();
			if (firstResult <= 0) {
				sqlPage = "select * from ( " + allSql + " ) where rownum <= " + maxResults;
			} else {
				sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + allSql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
			}
			// 连接池
			DBConnectionCustomManager connectionMan = null;
			String poolName = orgId + "_" + sysId;
			Connection conn = null;
			Statement statement = null;
			ResultSet rs = null;

			// add start by zyh 2015.06.15
			List<String> colIds = new ArrayList<String>();
			StringBuffer queryLookupSql = new StringBuffer();
			queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
			queryLookupSql.append(" WHERE T.COLUMN_ID IN (");
			// 获得存在通用代码列的列id
			for (int i = 0; i < formShowList.size(); i++) {
				CbbTabColumns ctcs = formShowList.get(i);
				if ("1".equals(ctcs.getColDropdownType()) || "2".equals(ctcs.getColDropdownType())) {
					queryLookupSql.append("'" + ctcs.getId() + "',");
					colIds.add(ctcs.getId());
				}
			}
			String querySql = "";
			if (queryLookupSql.toString().endsWith(",")) {
				querySql = queryLookupSql.substring(0, queryLookupSql.length() - 1) + ")";
			}
			// 查询出列中所需通用代码
			List<Map<String, Object>> lookupList = new ArrayList<Map<String, Object>>();
			if (colIds.size() > 0) {
				lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(querySql);
			}
			// 创建通用代码map便于赋值
			Map<String, Map<String, String>> lookupMapKeyValue = new HashMap<String, Map<String, String>>();
			for (int i = 0; i < colIds.size(); i++) {
				Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
				for (int j = 0; j < lookupList.size(); j++) {
					Map<String, Object> lookupMap = lookupList.get(j);
					if (colIds.get(i).equals(lookupMap.get("COLUMN_ID"))) {
						lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
					}
				}
				lookupMapKeyValue.put(colIds.get(i), lookupNameCodeMap);
			}
			// add end by zyh 2015.06.15
			try {
				// 实例化连接池
				connectionMan = DBConnectionCustomManager.getInstance(poolName);
				// 获取连接
				conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接

				statement = conn.createStatement();
				rs = statement.executeQuery(sqlCount);
				while (rs.next()) {
					count = rs.getLong(1);
				}
				rs = statement.executeQuery(sqlPage);
				int num = 0;
				while (rs.next()) {
					Map<String, Object> map = new HashMap<String, Object>();
					if (num == 0) {
						map.put("ROW_COUNT", count);
					}
					num++;
					// 循环基本字段进行赋值
					for (int i = 0; i < formShowList.size(); i++) {
						CbbTabColumns cbbTabColumns = formShowList.get(i);
						String cValue = "";// 具体的值
						String colName = cbbTabColumns.getColName();// 列名
						String colType = formShowList.get(i).getColType();// 列类型
						String colRuleName = formShowList.get(i).getColRuleName();// 列规则名称
						if ("string".equals(colType)) {
							cValue = rs.getString(colName);
						} else if ("integer".equals(colType)) {
							cValue = rs.getString(colName);
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("date".equals(colType)) {
							cValue = rs.getDate(colName) + "";
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("float".equals(colType)) {
							cValue = rs.getString(colName);
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("clob".equals(colType)) {
							Clob clobInData = rs.getClob(colName);
							if (null != clobInData) {
								int clobLength = (int) clobInData.length();
								cValue = clobInData.getSubString(1, clobLength);
							}
						}
						if ("1".equals(formShowList.get(i).getColDropdownType()) || "2".equals(formShowList.get(i).getColDropdownType())) {
							// add start by zyh 2015.06.15
							Map<String, String> showLookupMap = lookupMapKeyValue.get(formShowList.get(i).getId());
							map.put(colName, showLookupMap.get(cValue) == null ? cValue : showLookupMap.get(cValue));
							map.put(colName + "_CODE", cValue);
							// add end by zyh 2015.06.15
						} else if ("user".equals(colRuleName)) {
							if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
								String[] users = cValue.split(",");
								String usersName = "";
								String usersId = "";
								for (int q = 0; q < users.length; q++) {
									if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
										SysUser su = userLoader.getSysUserById(users[q]);
										if (null != su) {
											usersName = usersName + su.getName() + ",";
											usersId = usersId + users[q] + ",";
										} else {
											usersName = usersName + users[q] + ",";
											usersId = usersId + users[q] + ",";
										}
										// usersName = usersName +
										// userLoader.getSysUserById(users[q]).getName()
										// + ",";
										// usersId = usersId + users[q] + ",";
									}
								}
								usersName = usersName.substring(0, usersName.length() - 1);
								usersId = usersId.substring(0, usersId.length() - 1);
								map.put(colName, usersName);
								map.put(colName + "_CODE", usersId);
							}
						} else if ("dept".equals(colRuleName)) {
							if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
								String[] depts = cValue.split(",");
								String deptName = "";
								String deptIds = "";
								for (int q = 0; q < depts.length; q++) {
									if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
										SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
										if (null != sdt) {
											deptName = deptName + sdt.getDeptName() + ",";
											deptIds = deptIds + depts[q] + ",";
										} else {
											deptName = deptName + depts[q] + ",";
											deptIds = deptIds + depts[q] + ",";
										}
										// deptName = deptName +
										// deptLoader.getSysDeptTl(depts[q],
										// "zh_CN").getDeptName() + ",";
										// deptIds = deptIds + depts[q] + ",";
									}
								}
								deptName = deptName.substring(0, deptName.length() - 1);
								deptIds = deptIds.substring(0, deptIds.length() - 1);
								map.put(colName, deptName);
								map.put(colName + "_CODE", deptIds);
							}
						} else if ("custom".equals(colRuleName)) {
							if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
								String path = cbbTabColumns.getCustomPath();// 获取自定义页面路径
								// 截取表名，字段值
								if (!"".equals(path) && null != path) {
									String[] url = path.split("[?]");
									if (url.length > 1) {
										String[] arg = url[1].split("&");// 表名，字段值字符串
										if (arg.length > 1) {
											String cNames = "";// 返回的显示值字符串
											String tName = arg[0].split("=")[1];// 表名
											String cName = arg[1].split("=")[1];// 列名
											StringBuffer sbSqlCustom = new StringBuffer();
											sbSqlCustom.append("SELECT T." + cName + "\n");
											sbSqlCustom.append("  FROM " + tName + " T\n");
											sbSqlCustom.append(" WHERE T.ID IN (");
											String[] datas = cValue.split(",");
											for (int d = 0; d < datas.length; d++) {
												if (d == datas.length - 1) {
													sbSqlCustom.append("'" + datas[d] + "'\n");
												} else {
													sbSqlCustom.append("'" + datas[d] + "',\n");
												}
											}
											sbSqlCustom.append(")");
											// JDBC实现
											// 查询列的值，并且给attribute02赋值
											Statement statements = null;
											ResultSet rss = null;
											try {
												statements = conn.createStatement();
												rss = statements.executeQuery(sbSqlCustom.toString());
												while (rss.next()) {
													cNames = cNames + rss.getString(cName) + ",";
												}
												if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
													cNames = cNames.substring(0, cNames.length() - 1);
												}
												map.put(colName, cNames);
											} catch (Exception e) {
												e.printStackTrace();
												throw new Exception("数据库操作异常，请联系管理员！");
											} finally {
												if (rss != null) {
													try {
														rss.close();
														rss = null;
													} catch (Exception e) {
														e.printStackTrace();
													}
												}
												if (statements != null) {
													try {
														statements.close();
														statements = null;
													} catch (Exception e) {
														e.printStackTrace();
													}
												}
											}
										}
									}
								}
							}
						} else {
							map.put(colName, cValue);
						}
					}
					map.put("ID", rs.getString("ID"));
					list.add(map);
				}
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				if (rs != null) {
					try {
						rs.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (statement != null) {
					try {
						statement.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (conn != null) {
					try {
						connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
		return list;
	}

	/**
	 * 根据固定表集合，动态表ID及查询条件， 获取2层表结构（父-子）的列信息以及数据
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableName
	 * @param tableId
	 * @param pageNo
	 * @param pageSize
	 * @param serachMap
	 * @param leftJoinOnCondition
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasByTabColListAndTableIdByIntfs(String orgId, String deptId, String sysId, List<Map<String, Object>> tabColnumsList, String tableId, String pageNo, String pageSize, List<Map<String, Object>> serachMapFroT1List,
																						 Map<String, Object> serachMapFroT2, Map<String, String> leftJoinOnCondition) throws Exception {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		List<CbbTabColumns> formShowList = new ArrayList<CbbTabColumns>();
		String tableName = "";// 固定表英文名
		StringBuffer sb = new StringBuffer();
		if (!"".equals(tableId)) {
			sb.append("SELECT ");
			// 封装字段信息 T1
			for (int i = 0; i < tabColnumsList.size(); i++) {
				Map<String, Object> lmap = tabColnumsList.get(i);
				tableName = String.valueOf(lmap.get("TABLE_NAME"));// 固定表英文名
				String colName = String.valueOf(lmap.get("COL_NAME"));
				String colAsName = "T1_" + colName;
				sb.append(" T1.");
				sb.append(colName);
				sb.append(" AS ");
				sb.append(colAsName);
				sb.append(",");
			}
			// 封装字段信息 T2
			CbbTables cbbTables = getCbbTablesById(tableId);
			List<CbbTabColumns> formtListT2 = getFormShowTableList(tableId, "", cbbTables.getTableName(), "0", sysId, orgId, deptId, "");// 基本字段对象
			for (int j = 0; j < formtListT2.size(); j++) {
				CbbTabColumns cbbTabColumns = formtListT2.get(j);
				String colAsName = "T2_" + cbbTabColumns.getColName();
				sb.append(" T2.");
				sb.append(cbbTabColumns.getColName());
				sb.append(" AS ");
				sb.append(colAsName);
				sb.append(",");
				cbbTabColumns.setColName(colAsName);
				formShowList.add(cbbTabColumns);
			}
			sb.append("T2.ID AS T2_ID FROM ");
			sb.append(tableName);
			sb.append(" T1 LEFT JOIN ");
			sb.append(cbbTables.getTableName());
			String t1Left = leftJoinOnCondition.get("T1");
			String t2Left = leftJoinOnCondition.get("T2");
			sb.append(" T2 ON T2." + t2Left + " = T1." + t1Left + " WHERE 1=1");
			// 循环条件1
			for (int i = 0; i < serachMapFroT1List.size(); i++) {
				Map<String, Object> map = serachMapFroT1List.get(i);
				String colName = String.valueOf(map.get("colName"));
				String value = String.valueOf(map.get("colValue"));
				String colType = String.valueOf(map.get("colType"));
				if (!value.equals("")) {
					if ("string".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "='" + value + "'");
						}
					} else if ("integer".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "=" + value);
						}
					} else if ("date".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "= TO_DATE('" + value + "','yyyy-MM-dd')");
						}
					} else if ("float".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "=" + value);
						}
					} else if ("clob".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND DBMS_LOB.SUBSTR(" + colName + ",32767) like '%" + value + "%'");
						}
					}
				}
			}

			// 循环条件2
			Iterator iteratorT2 = serachMapFroT2.keySet().iterator();
			while (iteratorT2.hasNext()) {
				String colName = String.valueOf(iteratorT2.next());
				String value = String.valueOf(serachMapFroT2.get(colName));
				if (!value.equals("")) {
					String colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);// 获取该字段类型
					if ("string".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "='" + value + "'");
						}
					} else if ("integer".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "=" + value);
						}
					} else if ("date".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "= TO_DATE('" + value + "','yyyy-MM-dd')");
						}
					} else if ("float".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND " + colName + "=" + value);
						}
					} else if ("clob".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sb.append(" AND (" + colName + " IS NULL OR " + colName + " = '')");
						} else {
							sb.append(" AND DBMS_LOB.SUBSTR(" + colName + ",32767) like '%" + value + "%'");
						}
					}
				}
			}
			// T2表获取排序字段
			List<Map<String, Object>> sortlist = commTableManagerIntfsService.getColDataOrderByTableId(tableId, sysId, orgId, deptId);
			for (int i = 0; i < sortlist.size(); i++) {
				if (i == 0) {
					sb.append(" ORDER BY ");
				}
				Map<String, Object> sortMap = new HashMap<String, Object>();
				sortMap = sortlist.get(i);
				String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
				String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
				// A-升序，D-降序
				if ("A".equals(sortCode)) {
					sortCode = " ASC";
				} else {
					sortCode = " DESC";
				}
				sb.append("T2_" + colName + sortCode + ",");
			}
			String allSql = "";
			if (sortlist.size() > 0) {
				allSql = sb.substring(0, sb.length() - 1);
			} else {
				allSql = sb.toString();
			}
			// 构造PAGE对象
			String sqlPage = "";
			Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
			page.setPageSize(ComUtil.getPageSize(pageSize));
			page.setPageNo(ComUtil.getPageNo(pageNo));
			Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());
			String sqlCount = "select count(1) from (" + allSql + ")";
			long count = 0;
			int firstResult = pageBean.getFirstEntityIndex();
			int maxResults = pageBean.getRows();
			if (firstResult <= 0) {
				sqlPage = "select * from ( " + allSql + " ) where rownum <= " + maxResults;
			} else {
				sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + allSql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
			}
			// 连接池
			DBConnectionCustomManager connectionMan = null;
			String poolName = orgId + "_" + sysId;
			Connection conn = null;
			Statement statement = null;
			ResultSet rs = null;

			// add start by zyh 2015.06.15
			List<String> colIds = new ArrayList<String>();
			StringBuffer queryLookupSql = new StringBuffer();
			queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
			queryLookupSql.append(" WHERE T.COLUMN_ID IN (");
			// 获得存在通用代码列的列id
			for (int i = 0; i < formShowList.size(); i++) {
				CbbTabColumns ctcs = formShowList.get(i);
				if ("1".equals(ctcs.getColDropdownType()) || "2".equals(ctcs.getColDropdownType())) {
					queryLookupSql.append("'" + ctcs.getId() + "',");
					colIds.add(ctcs.getId());
				}
			}
			String querySql = "";
			if (queryLookupSql.toString().endsWith(",")) {
				querySql = queryLookupSql.substring(0, queryLookupSql.length() - 1) + ")";
			}
			// 查询出列中所需通用代码
			List<Map<String, Object>> lookupList = new ArrayList<Map<String, Object>>();
			if (colIds.size() > 0) {
				lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(querySql);
			}
			// 创建通用代码map便于赋值
			Map<String, Map<String, String>> lookupMapKeyValue = new HashMap<String, Map<String, String>>();
			for (int i = 0; i < colIds.size(); i++) {
				Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
				for (int j = 0; j < lookupList.size(); j++) {
					Map<String, Object> lookupMap = lookupList.get(j);
					if (colIds.get(i).equals(lookupMap.get("COLUMN_ID"))) {
						lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
					}
				}
				lookupMapKeyValue.put(colIds.get(i), lookupNameCodeMap);
			}
			// add end by zyh 2015.06.15

			try {
				// 实例化连接池
				connectionMan = DBConnectionCustomManager.getInstance(poolName);
				// 获取连接
				conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接

				statement = conn.createStatement();
				rs = statement.executeQuery(sqlCount);
				while (rs.next()) {
					count = rs.getLong(1);
				}
				rs = statement.executeQuery(sqlPage);
				int num = 0;
				while (rs.next()) {
					Map<String, Object> map = new HashMap<String, Object>();
					if (num == 0) {
						map.put("ROW_COUNT", count);
					}
					num++;
					// 循环固定表MAP，并且赋值
					for (int i = 0; i < tabColnumsList.size(); i++) {
						Map<String, Object> lmap = tabColnumsList.get(i);
						String cValue = "";// 具体的值
						String colName = "T1_" + String.valueOf(lmap.get("COL_NAME"));
						String colType = String.valueOf(lmap.get("COL_TYPE"));
						if ("string".equals(colType)) {
							cValue = rs.getString(colName);
						} else if ("integer".equals(colType)) {
							cValue = rs.getString(colName);
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("date".equals(colType)) {
							cValue = rs.getDate(colName) + "";
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("float".equals(colType)) {
							cValue = rs.getString(colName);
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("clob".equals(colType)) {
							Clob clobInData = rs.getClob(colName);
							if (null != clobInData) {
								int clobLength = (int) clobInData.length();
								cValue = clobInData.getSubString(1, clobLength);
							}
						}
						map.put(colName, cValue);
					}
					// 循环基本字段进行赋值
					for (int i = 0; i < formShowList.size(); i++) {
						CbbTabColumns cbbTabColumns = formShowList.get(i);
						String cValue = "";// 具体的值
						String colName = cbbTabColumns.getColName();// 列名
						String colType = formShowList.get(i).getColType();// 列类型
						String colRuleName = formShowList.get(i).getColRuleName();// 列规则名称
						if ("string".equals(colType)) {
							cValue = rs.getString(colName);
						} else if ("integer".equals(colType)) {
							cValue = rs.getString(colName);
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("date".equals(colType)) {
							cValue = rs.getDate(colName) + "";
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("float".equals(colType)) {
							cValue = rs.getString(colName);
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("clob".equals(colType)) {
							Clob clobInData = rs.getClob(colName);
							if (null != clobInData) {
								int clobLength = (int) clobInData.length();
								cValue = clobInData.getSubString(1, clobLength);
							}
						}
						if ("1".equals(formShowList.get(i).getColDropdownType()) || "2".equals(formShowList.get(i).getColDropdownType())) {
							// StringBuffer sbSql = new StringBuffer();
							// sbSql.append("SELECT T.LOOKUP_NAME\n");
							// sbSql.append("  FROM CBB_TAB_LOOKUP_V T\n");
							// sbSql.append(" WHERE T.COLUMN_ID = '"
							// + cbbTabColumns.getId() + "'\n");
							// sbSql.append("   AND T.LOOKUP_CODE = '" + cValue
							// + "'");
							// List<Object> listValue = hibernateDao
							// .findBySQL(sbSql.toString());
							// String codeName = "";
							// String codeCode = "";
							// if (listValue.size() != 0) {
							// codeName = String.valueOf(listValue.get(0));//
							// 获取该列该值所对应的通用代码名称
							// } else {
							// codeName = cValue;
							// }
							// codeCode = cValue;
							// map.put(colName, codeName);
							// map.put(colName + "_CODE", codeCode);

							// add start by zyh 2015.06.15
							Map<String, String> showLookupMap = lookupMapKeyValue.get(formShowList.get(i).getId());
							map.put(colName, showLookupMap.get(cValue) == null ? cValue : showLookupMap.get(cValue));
							map.put(colName + "_CODE", cValue);
							// add end by zyh 2015.06.15
						} else if ("user".equals(colRuleName)) {
							if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
								String[] users = cValue.split(",");
								String usersName = "";
								String usersId = "";
								for (int q = 0; q < users.length; q++) {
									if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
										SysUser su = userLoader.getSysUserById(users[q]);
										if (null != su) {
											usersName = usersName + su.getName() + ",";
											usersId = usersId + users[q] + ",";
										} else {
											usersName = usersName + users[q] + ",";
											usersId = usersId + users[q] + ",";
										}
										// usersName = usersName +
										// userLoader.getSysUserById(users[q]).getName()
										// + ",";
										// usersId = usersId + users[q] + ",";
									}
								}
								usersName = usersName.substring(0, usersName.length() - 1);
								usersId = usersId.substring(0, usersId.length() - 1);
								map.put(colName, usersName);
								map.put(colName + "_CODE", usersId);
							}
						} else if ("dept".equals(colRuleName)) {
							if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
								String[] depts = cValue.split(",");
								String deptName = "";
								String deptIds = "";
								for (int q = 0; q < depts.length; q++) {
									if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
										SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
										if (null != sdt) {
											deptName = deptName + sdt.getDeptName() + ",";
											deptIds = deptIds + depts[q] + ",";
										} else {
											deptName = deptName + depts[q] + ",";
											deptIds = deptIds + depts[q] + ",";
										}
										// deptName = deptName +
										// deptLoader.getSysDeptTl(depts[q],
										// "zh_CN").getDeptName() + ",";
										// deptIds = deptIds + depts[q] + ",";
									}
								}
								deptName = deptName.substring(0, deptName.length() - 1);
								deptIds = deptIds.substring(0, deptIds.length() - 1);
								map.put(colName, deptName);
								map.put(colName + "_CODE", deptIds);
							}
						} else if ("custom".equals(colRuleName)) {
							if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
								String path = cbbTabColumns.getCustomPath();// 获取自定义页面路径
								// 截取表名，字段值
								if (!"".equals(path) && null != path) {
									String[] url = path.split("[?]");
									if (url.length > 1) {
										String[] arg = url[1].split("&");// 表名，字段值字符串
										if (arg.length > 1) {
											String cNames = "";// 返回的显示值字符串
											String tName = arg[0].split("=")[1];// 表名
											String cName = arg[1].split("=")[1];// 列名
											StringBuffer sbSqlCustom = new StringBuffer();
											sbSqlCustom.append("SELECT T." + cName + "\n");
											sbSqlCustom.append("  FROM " + tName + " T\n");
											sbSqlCustom.append(" WHERE T.ID IN (");
											String[] datas = cValue.split(",");
											for (int d = 0; d < datas.length; d++) {
												if (d == datas.length - 1) {
													sbSqlCustom.append("'" + datas[d] + "'\n");
												} else {
													sbSqlCustom.append("'" + datas[d] + "',\n");
												}
											}
											sbSqlCustom.append(")");
											// JDBC实现
											// 查询列的值，并且给attribute02赋值
											Statement statements = null;
											ResultSet rss = null;
											try {
												statements = conn.createStatement();
												rss = statements.executeQuery(sbSqlCustom.toString());
												while (rss.next()) {
													cNames = cNames + rss.getString(cName) + ",";
												}
												if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
													cNames = cNames.substring(0, cNames.length() - 1);
												}
												map.put(colName, cNames);
											} catch (Exception e) {
												e.printStackTrace();
												throw new Exception("数据库操作异常，请联系管理员！");
											} finally {
												if (rss != null) {
													try {
														rss.close();
														rss = null;
													} catch (Exception e) {
														e.printStackTrace();
													}
												}
												if (statements != null) {
													try {
														statements.close();
														statements = null;
													} catch (Exception e) {
														e.printStackTrace();
													}
												}
											}
										}
									}
								}
							}
						} else {
							map.put(colName, cValue);
						}
					}
					map.put("T2_ID", rs.getString("T2_ID"));
					list.add(map);
				}
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				if (rs != null) {
					try {
						rs.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (statement != null) {
					try {
						statement.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (conn != null) {
					try {
						connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
		return list;
	}

	/**
	 * 根据SQL查询所需要的数据（带分页，供列表显示）
	 *
	 * @author 朱锋
	 * @param sql
	 * @param pageNo
	 * @param pageSize
	 * @param sysId
	 * @param allListColName
	 *            （列别名必须以:表别名_列名，格式）
	 * @param orgId
	 * @param deptId
	 * @param tableMap
	 *            （TABLE_ID：表ID，TABLE_FLAG：表别名）
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasBySqlByIntfs(String sql, String pageNo, String pageSize, String sysId, List<String> allListColName, String orgId, String deptId, Map<String, Object> tableMap) throws Exception {
		// add start by zyh------------
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		String tableId = (String) tableMap.get("TABLE_ID");
		String tableFlag = (String) tableMap.get("TABLE_FLAG");// 表别名
		List<CbbTabColumns> formShowList = new ArrayList<CbbTabColumns>();
		if (null != tableId && !"".equals(tableId)) {
			CbbTables cbbTables = getCbbTablesById(tableId);
			// 全部字段对象
			if (null != tableId && !"".equals(tableId) && null != cbbTables && !"".equals(cbbTables.getTableName())) {
				formShowList = getFormShowTableList(tableId, "", cbbTables.getTableName(), "0", sysId, orgId, deptId, "");
			}
		}
		// add end by zyh--------------

		// add start by zyh 2015.06.15
		List<String> colIds = new ArrayList<String>();
		StringBuffer queryLookupSql = new StringBuffer();
		queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
		queryLookupSql.append(" WHERE T.COLUMN_ID IN (");
		// 获得存在通用代码列的列id
		for (int i = 0; i < formShowList.size(); i++) {
			CbbTabColumns ctcs = formShowList.get(i);
			if ("1".equals(ctcs.getColDropdownType()) || "2".equals(ctcs.getColDropdownType())) {
				queryLookupSql.append("'" + ctcs.getId() + "',");
				colIds.add(ctcs.getId());
			}
		}
		String querySql = "";
		if (queryLookupSql.toString().endsWith(",")) {
			querySql = queryLookupSql.substring(0, queryLookupSql.length() - 1) + ")";
		}
		// 查询出列中所需通用代码
		List<Map<String, Object>> lookupList = new ArrayList<Map<String, Object>>();
		if (colIds.size() > 0) {
			lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(querySql);
		}
		// 创建通用代码map便于赋值
		Map<String, Map<String, String>> lookupMapKeyValue = new HashMap<String, Map<String, String>>();
		for (int i = 0; i < colIds.size(); i++) {
			Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
			for (int j = 0; j < lookupList.size(); j++) {
				Map<String, Object> lookupMap = lookupList.get(j);
				if (colIds.get(i).equals(lookupMap.get("COLUMN_ID"))) {
					lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
				}
			}
			lookupMapKeyValue.put(colIds.get(i), lookupNameCodeMap);
		}
		// add end by zyh 2015.06.15

		// 构造PAGE对象
		String sqlPage = "";
		Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
		page.setPageSize(ComUtil.getPageSize(pageSize));
		page.setPageNo(ComUtil.getPageNo(pageNo));
		Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());
		String sqlCount = "select count(1) from (" + sql + ")";
		long count = 0;
		int firstResult = pageBean.getFirstEntityIndex();
		int maxResults = pageBean.getRows();
		if (firstResult <= 0) {
			sqlPage = "select * from ( " + sql + " ) where rownum <= " + maxResults;
		} else {
			sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + sql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			rs = statement.executeQuery(sqlCount);
			while (rs.next()) {
				count = rs.getLong(1);
			}
			rs = statement.executeQuery(sqlPage);
			int num = 0;
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				if (num == 0) {
					map.put("ROW_COUNT", count);
				}
				num++;
				for (int i = 0; i < allListColName.size(); i++) {
					String allColName = allListColName.get(i);
					String value = rs.getString(allColName);
					int colIndex = allColName.indexOf("_");
					if (colIndex == -1) {
						map.put(allColName, value);
					} else {
						String sourceFlag = allColName.substring(0, colIndex);
						String sourceColName = allColName.substring(colIndex + 1, allColName.length());
						if (null != tableId && !"".equals(tableId) && null != tableFlag && null != sourceFlag && sourceFlag.equals(tableFlag)) {

							for (int j = 0; j < formShowList.size(); j++) {
								CbbTabColumns ctc = formShowList.get(j);
								// 列名
								String colName = ctc.getColName();
								// 列类型
								String colType = ctc.getColType();
								// 列规则名称
								String colRuleName = ctc.getColRuleName();
								if (sourceColName.equals(colName)) {
									if ("string".equals(colType)) {
										value = rs.getString(allColName);
									} else if ("integer".equals(colType)) {
										value = rs.getString(allColName);
										value = "null".equals(value) ? "" : value;
									} else if ("date".equals(colType)) {
										value = rs.getDate(allColName) + "";
										value = "null".equals(value) ? "" : value;
									} else if ("float".equals(colType)) {
										value = rs.getString(allColName);
										value = "null".equals(value) ? "" : value;
									} else if ("clob".equals(colType)) {
										Clob clobInData = rs.getClob(allColName);
										if (null != clobInData) {
											int clobLength = (int) clobInData.length();
											value = clobInData.getSubString(1, clobLength);
										}
									}
									if ("1".equals(formShowList.get(j).getColDropdownType()) || "2".equals(formShowList.get(j).getColDropdownType())) {
										// StringBuffer sbSql = new
										// StringBuffer();
										// sbSql.append("SELECT T.LOOKUP_NAME\n");
										// sbSql.append("  FROM CBB_TAB_LOOKUP_V T\n");
										// sbSql.append(" WHERE T.COLUMN_ID = '"
										// + formShowList.get(j).getId()
										// + "'\n");
										// sbSql.append("   AND T.LOOKUP_CODE = '"
										// + value + "'");
										// List<Object> listValue = hibernateDao
										// .findBySQL(sbSql.toString());
										// String codeName = "";
										// String codeCode = "";
										// if (listValue.size() != 0) {
										// codeName = String.valueOf(listValue
										// .get(0));// 获取该列该值所对应的通用代码名称
										// } else {
										// codeName = value;
										// }
										// codeCode = value;
										// map.put(allColName, codeName);
										// map.put(allColName + "_CODE",
										// codeCode);

										// add start by zyh 2015.06.15
										Map<String, String> showLookupMap = lookupMapKeyValue.get(formShowList.get(j).getId());
										map.put(allColName, showLookupMap.get(value) == null ? value : showLookupMap.get(value));
										map.put(allColName + "_CODE", value);
										// add end by zyh 2015.06.15
									} else if ("user".equals(colRuleName)) {
										if (!"".equals(value) && null != value && !"null".equals(value)) {
											String[] users = value.split(",");
											String usersName = "";
											String userId = "";
											for (int q = 0; q < users.length; q++) {
												if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
													SysUser su = userLoader.getSysUserById(users[q]);
													if (null != su) {
														usersName = usersName + su.getName() + ",";
														userId = userId + users[q] + ",";
													} else {
														usersName = usersName + users[q] + ",";
														userId = userId + users[q] + ",";
													}
													// usersName = usersName +
													// userLoader.getSysUserById(users[q]).getName()
													// + ",";
													// userId = userId +
													// users[q] + ",";
												}
											}
											usersName = usersName.substring(0, usersName.length() - 1);
											userId = userId.substring(0, userId.length() - 1);
											map.put(allColName, usersName);
											map.put(allColName + "_CODE", userId);
										}
									} else if ("dept".equals(colRuleName)) {
										if (!"".equals(value) && null != value && !"null".equals(value)) {
											String[] depts = value.split(",");
											String deptName = "";
											String deptIds = "";
											for (int q = 0; q < depts.length; q++) {
												if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
													SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
													if (null != sdt) {
														deptName = deptName + sdt.getDeptName() + ",";
														deptIds = deptIds + depts[q] + ",";
													} else {
														deptName = deptName + depts[q] + ",";
														deptIds = deptIds + depts[q] + ",";
													}
													// deptName = deptName +
													// deptLoader.getSysDeptTl(depts[q],
													// "zh_CN").getDeptName() +
													// ",";
													// deptIds = deptIds +
													// depts[q] + ",";
												}
											}
											deptName = deptName.substring(0, deptName.length() - 1);
											deptIds = deptIds.substring(0, deptIds.length() - 1);
											map.put(allColName, deptName);
											map.put(allColName + "_CODE", deptIds);
										}
									} else if ("custom".equals(colRuleName)) {
										if (!"".equals(value) && null != value && !"null".equals(value)) {
											String path = formShowList.get(i).getCustomPath();// 获取自定义页面路径
											// 截取表名，字段值
											if (!"".equals(path) && null != path) {
												String[] url = path.split("[?]");
												if (url.length > 1) {
													String[] arg = url[1].split("&");// 表名，字段值字符串
													if (arg.length > 1) {
														String cNames = "";// 返回的显示值字符串
														String tName = arg[0].split("=")[1];// 表名
														String cName = arg[1].split("=")[1];// 列名
														StringBuffer sbSqlCustom = new StringBuffer();
														sbSqlCustom.append("SELECT T." + cName + "\n");
														sbSqlCustom.append("  FROM " + tName + " T\n");
														sbSqlCustom.append(" WHERE T.ID IN (");
														String[] datas = value.split(",");
														for (int d = 0; d < datas.length; d++) {
															if (d == datas.length - 1) {
																sbSqlCustom.append("'" + datas[d] + "'\n");
															} else {
																sbSqlCustom.append("'" + datas[d] + "',\n");
															}
														}
														sbSqlCustom.append(")");
														// JDBC实现
														// 查询列的值，并且给attribute02赋值
														Statement statements = null;
														ResultSet rss = null;
														try {
															statements = conn.createStatement();
															rss = statements.executeQuery(sbSqlCustom.toString());
															while (rss.next()) {
																cNames = cNames + rss.getString(cName) + ",";
															}
															if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
																cNames = cNames.substring(0, cNames.length() - 1);
															}
															map.put(allColName, cNames);
														} catch (Exception e) {
															e.printStackTrace();
															throw new Exception("数据库操作异常，请联系管理员！");
														} finally {
															if (rss != null) {
																try {
																	rss.close();
																	rss = null;
																} catch (Exception e) {
																	e.printStackTrace();
																}
															}
															if (statements != null) {
																try {
																	statements.close();
																	statements = null;
																} catch (Exception e) {
																	e.printStackTrace();
																}
															}
														}
													}
												}
											}
										}
									} else {
										map.put(allColName, value);
									}
								}
							}
						} else {
							map.put(allColName, value);
						}
					}
				}
				//判断是否list中是否存在'LDV_ORG_ID'
				boolean ifColName = false;
				for (int i = 0; i < allListColName.size(); i++) {
					String ldvOrgId = allListColName.get(i);
					if(ldvOrgId .equals("LDV_ORG_ID")){
						ifColName = true;
						break;
					}
				}
				//判断rs中是否存在列"LDV_ORG_ID"
				if(!ifColName && isExistColumn(rs,"LDV_ORG_ID")){
					String value = rs.getString("LDV_ORG_ID");
					map.put("LDV_ORG_ID", value);
				}

				list.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return list;
	}

	/**
	 * 根据CbbSQL查询所需要的数据（带分页，供列表显示）
	 *
	 * @author 朱锋
	 * @param sql
	 * @param pageNo
	 *            (如果为空字符串，那么不提供分页功能)
	 * @param pageSize
	 *            (如果为空字符串，那么不提供分页功能)
	 * @param sysId
	 * @param allListColName
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasByCbbSqlByIntfs(String orgId, String deptId, String sql, String pageNo, String pageSize, String sysId, List<String> allListColName, List<String> fixColName, String searchSql, Map<String, Object> param) throws Exception {
		String orgCode = (String) param.get("orgCode");
		List<Map<String, Object>> listFond = cbbFondsDbIntfsService.getCbbFondsDbInfoByIntfs(orgId, deptId, sysId, orgId);
		String dbUser = "";// 用户名
		if (listFond.size() > 0) {
			Map<String, Object> map = listFond.get(0);
			dbUser = String.valueOf(map.get("DB_USER"));
		}
		

		String tempOrgCode = orgCode;
		if (orgCode.length() > 16) {
			tempOrgCode = orgCode.substring(orgCode.length() - 16);
		}

		/*
		 * // 循环大视图列 StringBuffer bigDataSql = new StringBuffer(); for (int i = 0; i < allListColName.size(); i++) { bigDataSql.append(allListColName.get(i)); if (i !=
		 * allListColName.size() - 1) { bigDataSql.append(","); } }
		 */

		// 查找公共字段表字段所有字段
		/*List<Map<String, String>> pubFieldsList = new ArrayList<Map<String, String>>(); // 公共字段集合
		StringBuffer pubFieldSql = new StringBuffer();
		pubFieldSql.append("SELECT CTC.COL_NAME,CTC.COL_DROPDOWN_TYPE,CTC.COL_TYPE,CTC.COL_RULE_NAME,CTC.ID\n");
		pubFieldSql.append("  FROM CBB_TAB_COLUMNS CTC\n");
		pubFieldSql.append("  LEFT JOIN CBB_TABLES CT\n");
		pubFieldSql.append("    ON CT.ID = CTC.TABLE_ID\n");
		pubFieldSql.append(" WHERE CT.TABLE_NAME = 'LANTOP_PUB_FIELD'");
		List<Map<String, Object>> list = this.jdbcAvicit.queryForMap(pubFieldSql.toString(), null);
		for (int i = 0; i < list.size(); i++) {
			Map mapCol = list.get(i);
			String colName = String.valueOf(mapCol.get("COL_NAME"));
			String dropdownType = String.valueOf(mapCol.get("COL_DROPDOWN_TYPE"));
			String type = String.valueOf(mapCol.get("COL_TYPE"));
			String ruleName = String.valueOf(mapCol.get("COL_RULE_NAME"));
			String id = String.valueOf(mapCol.get("ID"));
			Map<String, String> map = new HashMap<String, String>();
			map.put("COL_NAME", colName);
			map.put("COL_DROPDOWN_TYPE", dropdownType);
			map.put("COL_TYPE", type);
			map.put("COL_RULE_NAME", ruleName);
			map.put("ID", id);
			pubFieldsList.add(map);
		}*/
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("WITH T1 AS\n");
		sbSql.append(" ( " + sql + " )\n");
		/*sbSql.append("T2 AS\n");
		sbSql.append(" (SELECT T1.*,\n");
		sbSql.append("(select ww.archive_class_node_name \n");
		sbSql.append("from LANTOP_ARCHIVE_CLASS ww where ww.id= \n");
		sbSql.append("(select s.parent_id \n");
		sbSql.append("from LANTOP_ARCHIVE_CLASS s\n");
		sbSql.append("where s.id=LDV.LANTOP_NODE_ID))\n");
		sbSql.append("as DALX,\n");*/
		// 循环公共字段集合拼接sql语句
		/*if (null != pubFieldsList && pubFieldsList.size() > 0) {
			for (int i = 0; i < pubFieldsList.size(); i++) {
				String name = pubFieldsList.get(i).get("COL_NAME");
				String dropddownType = pubFieldsList.get(i).get("COL_DROPDOWN_TYPE");
				String type = pubFieldsList.get(i).get("COL_TYPE");
				String cid = pubFieldsList.get(i).get("ID");
				if ("1".equals(dropddownType) || "2".equals(dropddownType)) {
					StringBuffer sbSql1 = new StringBuffer();
					sbSql1.append("(SELECT LLV.LOOKUP_NAME\n");
					sbSql1.append("  FROM LANTOP_LOOKUP_V LLV\n");
					sbSql1.append("  LEFT JOIN CBB_TAB_COL_SYS_CODE CTCSC ON CTCSC.SYS_LOOKUP_ID = LLV.ID\n");
					sbSql1.append(" WHERE CTCSC.COLUMN_ID = '" + cid + "'\n");
					sbSql1.append("   AND LLV.LOOKUP_CODE = " + name + "_CODE\n");
					sbSql1.append("UNION \n");
					sbSql1.append("SELECT CTCC.LOOKUP_NAME\n");
					sbSql1.append("  FROM CBB_TAB_COL_CODE CTCC\n");
					sbSql1.append(" WHERE CTCC.LOOKUP_CODE = " + name + "_CODE\n");
					sbSql1.append("   AND CTCC.ID = '" + cid + "') AS " + name + ",\n");
					sbSql.append(sbSql1.toString());
					sbSql.append(name + "_CODE,\n");
				} else if ("3".equals(dropddownType)) {
					sbSql.append(name + ",\n");
					sbSql.append(name + "_ID,\n");
				} else {
					if ("date".equals(type)) {
						sbSql.append("TO_CHAR(" + name + ",'yyyy-MM-dd') AS " + name + ",\n");
					} else {
						sbSql.append(name + ",\n");
					}
				}
			}
		}
		sbSql.append("         (SELECT LOOKUP_NAME\n");
		sbSql.append("            FROM CBB_LOOKUP_V\n");
		sbSql.append("           WHERE LOOKUP_TYPE = 'LANTOP_ARCHIVE_TYPE'\n");
		sbSql.append("             AND LOOKUP_CODE = (SELECT ARCHIVE_TYPE\n");
		sbSql.append("                                  FROM LANTOP_ARCHIVE_CLASS\n");
		sbSql.append("                                 WHERE ID = LDV.LANTOP_NODE_ID)) AS ARCHIVE_NAME,\n");
		sbSql.append("         LDV.LANTOP_NODE_ID,\n");
		sbSql.append("         LDV.LANTOP_RCD_ID AS LANTOP_FJ_RCD_ID,\n");
		sbSql.append("         LDV.PARENT_ID,\n");
		sbSql.append("         LDV.PUBLISH_STATUS,\n");
		sbSql.append("         LDV.LANTOP_ARCHIVE_STATUS,\n");
		sbSql.append("         (SELECT ARCHIVE_CLASS_NODE_CODE\n");
		sbSql.append("            FROM LANTOP_ARCHIVE_CLASS\n");
		sbSql.append("           WHERE ARCHIVE_TYPE IS NOT NULL\n");
		sbSql.append("             AND ARCHIVE_TYPE NOT IN ('-1', '0', '10')\n");
		sbSql.append("          CONNECT BY PRIOR PARENT_ID = ID\n");
		sbSql.append("           START WITH ID = LDV.LANTOP_NODE_ID) AS ARCHIVE_CLASS_NODE_CODE,\n");
		sbSql.append("         (SELECT ARCHIVE_CLASS_NODE_NAME\n");
		sbSql.append("            FROM LANTOP_ARCHIVE_CLASS\n");
		sbSql.append("           WHERE ARCHIVE_TYPE IS NOT NULL\n");
		sbSql.append("             AND ARCHIVE_TYPE NOT IN ('-1', '0', '10')\n");
		sbSql.append("          CONNECT BY PRIOR PARENT_ID = ID\n");
		sbSql.append("           START WITH ID = LDV.LANTOP_NODE_ID) AS ARCHIVE_CLASS_NODE_NAME,\n");
		sbSql.append("         (SELECT LLAC.ARCHIVE_TYPE\n");
		sbSql.append("            FROM CBB_TAB_NODE TCTN\n");
		sbSql.append("            LEFT JOIN LANTOP_ARCHIVE_CLASS LLAC\n");
		sbSql.append("              ON LLAC.ID = TCTN.NODE_ID\n");
		sbSql.append("           WHERE TCTN.TABLE_ID = LDV.ARCHIVE_TABLE_ID\n");
		sbSql.append("             AND LLAC.ARCHIVE_TYPE IS NOT NULL) AS ARCHIVE_TYPE,\n");
		sbSql.append("         LDV.ARCHIVE_TABLE_ID,\n");
		sbSql.append("         (SELECT DECODE(SUBSTR(LDV.ARCHIVE_TABLE_NAME, -3, 3),\n");
		sbSql.append("                        'AJJ',\n");
		sbSql.append("                        'AJJ',\n");
		sbSql.append("                        'WJJ')\n");
		sbSql.append("            FROM CBB_TAB_NODE\n");
		sbSql.append("           WHERE TABLE_ID = LDV.ARCHIVE_TABLE_ID\n");
		sbSql.append("             AND NODE_ID = LANTOP_NODE_ID\n");
		sbSql.append("             AND ROWNUM <= 1) AS ARCHIVE_TABLE_LEVEL,\n");
		sbSql.append("         LDV.ARCHIVE_TABLE_TITLE,\n");
		sbSql.append("         LDV.ARCHIVE_TABLE_NAME,\n");
		sbSql.append("         LDV.LANTOP_RCD_ID,\n");
		sbSql.append("         (SELECT LOOKUP_NAME\n");
		sbSql.append("            FROM SYS_LOOKUP_V\n");
		sbSql.append("           WHERE LOOKUP_TYPE = 'CBB_SECRET'\n");
		sbSql.append("             AND LOOKUP_CODE = LDV.MJ_CODE) AS ARCHIVE_RCD_SECRET,\n");
		sbSql.append("         LDV.CREATION_DATE,\n");
		sbSql.append("         LDV.CREATED_BY,\n");
		sbSql.append("         LDV.ARCHIVE_MULTIMEDIA_TYPE,\n");
		sbSql.append("         LDV.QZH,\n");
		sbSql.append("         (SELECT COUNT(CDR.ATTACHMENT_ID)\n");
		sbSql.append("            FROM CBB_DOC_RELATION CDR\n");
		sbSql.append("           WHERE CDR.RECORD_ID = LDV.LANTOP_RCD_ID\n");
		sbSql.append("             AND CDR.IF_DELETE = 'N') AS QWS\n");
		sbSql.append("    FROM T1\n");*/
		
		/*if (dbUser != null && !"".equals(dbUser)) {
			sbSql.append("   INNER JOIN " + dbUser + "." + sysId + "_DATA_V_"+tempOrgCode+" LDV\n");
		} else {
			sbSql.append("   INNER JOIN " + sysId + "_DATA_V_"+tempOrgCode+" LDV\n");
		}
		sbSql.append("      ON T1.RECORD_ID = LDV." + sysId + "_RCD_ID WHERE LANTOP_ARCHIVE_STATUS='3' OR LANTOP_ARCHIVE_STATUS='4')\n");
		sbSql.append("SELECT T2.* FROM T2 WHERE 1 = 1 ");*/

		sbSql.append(" SELECT * FROM  " + sysId + "_DATA_V_"+tempOrgCode+" V1 INNER JOIN T1 ON V1.LANTOP_RCD_ID=T1.RECORD_ID WHERE 1=1 AND (LANTOP_ARCHIVE_STATUS='3' OR LANTOP_ARCHIVE_STATUS='4') ");

		if (!"".equals(searchSql)) {
			sbSql.append(searchSql);
		}
		String sbSqlStr = sbSql.toString();

		// 构造PAGE对象
		String sqlPage = "";
		String sqlCount = "SELECT COUNT(1) AS COUNT FROM (" + sbSqlStr + ")";
		long count = 0;
		List<Map<String, Object>> listCount = jdbcAvicit.queryForMap(sqlCount, null);
		count = Integer.parseInt(String.valueOf(listCount.get(0).get("COUNT")));
		if (!"".equals(pageNo) && !"".equals(pageSize)) {
			Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
			page.setPageSize(ComUtil.getPageSize(pageSize));
			page.setPageNo(ComUtil.getPageNo(pageNo));
			Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());

			int firstResult = pageBean.getFirstEntityIndex();
			int maxResults = pageBean.getRows();
			if (firstResult <= 0) {
				sqlPage = "select * from ( " + sbSqlStr + " ) where rownum <= " + maxResults;
			} else {
				sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + sbSqlStr + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
			}
		} else {
			sqlPage = sbSqlStr;
		}
		List<Map<String, Object>> listSqlDatas = jdbcAvicit.queryForMap(sqlPage, null);
		if (listSqlDatas != null && listSqlDatas.size() > 0) {
			Map<String, Object> mapCount = new HashMap<String, Object>();
			mapCount = listSqlDatas.get(0);
			mapCount.put("ROW_COUNT", count);
		}
		if (listSqlDatas == null || listSqlDatas.size() == 0) {
			listSqlDatas = new ArrayList<Map<String, Object>>();
		}
		if (null != commTableSysFieldLoader.getAttachmentClassName() && !"".equals(commTableSysFieldLoader.getAttachmentClassName())) {
			this.fileUploadIntfsService.getAttachClassification(listSqlDatas);
		}
		return listSqlDatas;
	}

	/**
	 * 根据CbbSQL查询所需要的数据（带分页，供列表显示）
	 *
	 * @author 赵晓龙 备注：编研车调用查询数据方法重写
	 * @param sql
	 * @param pageNo
	 *            (如果为空字符串，那么不提供分页功能)
	 * @param pageSize
	 *            (如果为空字符串，那么不提供分页功能)
	 * @param sysId
	 * @param allListColName
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasByCbbSqlByIntfs(String orgId, String deptId, String sql, String pageNo, String pageSize, String sysId, List<String> allListColName, List<String> fixColName, String searchSql, Map<String, Object> param, String otherFlag) throws Exception {
		// 重写
		String ztby =  param.get("ztby")==null?"":param.get("ztby").toString();
		String orgCode = (String) param.get("orgCode");
		List<Map<String, Object>> listFond = cbbFondsDbIntfsService.getCbbFondsDbInfoByIntfs(orgId, deptId, sysId, orgId);
		String dbUser = "";// 用户名
		if (listFond.size() > 0) {
			Map<String, Object> map = listFond.get(0);
			dbUser = String.valueOf(map.get("DB_USER"));
		}
		
		String tempOrgCode = orgCode;
		if (orgCode.length() > 16) {
			tempOrgCode = orgCode.substring(orgCode.length() - 16);
		}
		

		/*
		 * // 循环大视图列 StringBuffer bigDataSql = new StringBuffer(); for (int i = 0; i < allListColName.size(); i++) { bigDataSql.append(allListColName.get(i)); if (i !=
		 * allListColName.size() - 1) { bigDataSql.append(","); } }
		 */

		// 查找公共字段表字段所有字段
		/*List<Map<String, String>> pubFieldsList = new ArrayList<Map<String, String>>(); // 公共字段集合
		StringBuffer pubFieldSql = new StringBuffer();
		pubFieldSql.append("SELECT CTC.COL_NAME,CTC.COL_DROPDOWN_TYPE,CTC.COL_TYPE,CTC.COL_RULE_NAME,CTC.ID\n");
		pubFieldSql.append("  FROM CBB_TAB_COLUMNS CTC\n");
		pubFieldSql.append("  LEFT JOIN CBB_TABLES CT\n");
		pubFieldSql.append("    ON CT.ID = CTC.TABLE_ID\n");
		pubFieldSql.append(" WHERE CT.TABLE_NAME = 'LANTOP_PUB_FIELD'");
		List<Map<String, Object>> list = this.jdbcAvicit.queryForMap(pubFieldSql.toString(), null);
		for (int i = 0; i < list.size(); i++) {
			Map mapCol = list.get(i);
			String colName = String.valueOf(mapCol.get("COL_NAME"));
			String dropdownType = String.valueOf(mapCol.get("COL_DROPDOWN_TYPE"));
			String type = String.valueOf(mapCol.get("COL_TYPE"));
			String ruleName = String.valueOf(mapCol.get("COL_RULE_NAME"));
			String id = String.valueOf(mapCol.get("ID"));
			Map<String, String> map = new HashMap<String, String>();
			map.put("COL_NAME", colName);
			map.put("COL_DROPDOWN_TYPE", dropdownType);
			map.put("COL_TYPE", type);
			map.put("COL_RULE_NAME", ruleName);
			map.put("ID", id);
			pubFieldsList.add(map);
		}*/
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("WITH T1 AS\n");
		sbSql.append(" ( " + sql + " )\n");
		// sbSql.append("T2 AS\n");
		/*sbSql.append(" (SELECT T1.*,\n");
		sbSql.append("(select ww.archive_class_node_name \n");
		sbSql.append("from LANTOP_ARCHIVE_CLASS ww where ww.id= \n");
		sbSql.append("(select s.parent_id \n");
		sbSql.append("from LANTOP_ARCHIVE_CLASS s\n");
		sbSql.append("where s.id=LDV.LANTOP_NODE_ID))\n");
		sbSql.append("as DALX,\n");
		// 循环公共字段集合拼接sql语句
		if (null != pubFieldsList && pubFieldsList.size() > 0) {
			for (int i = 0; i < pubFieldsList.size(); i++) {
				String name = pubFieldsList.get(i).get("COL_NAME");
				String dropddownType = pubFieldsList.get(i).get("COL_DROPDOWN_TYPE");
				String type = pubFieldsList.get(i).get("COL_TYPE");
				String cid = pubFieldsList.get(i).get("ID");
				if ("1".equals(dropddownType) || "2".equals(dropddownType)) {
					StringBuffer sbSql1 = new StringBuffer();
					sbSql1.append("(SELECT LLV.LOOKUP_NAME\n");
					sbSql1.append("  FROM LANTOP_LOOKUP_V LLV\n");
					sbSql1.append("  LEFT JOIN CBB_TAB_COL_SYS_CODE CTCSC ON CTCSC.SYS_LOOKUP_ID = LLV.ID\n");
					sbSql1.append(" WHERE CTCSC.COLUMN_ID = '" + cid + "'\n");
					sbSql1.append("   AND LLV.LOOKUP_CODE = " + name + "_CODE\n");
					sbSql1.append("UNION \n");
					sbSql1.append("SELECT CTCC.LOOKUP_NAME\n");
					sbSql1.append("  FROM CBB_TAB_COL_CODE CTCC\n");
					sbSql1.append(" WHERE CTCC.LOOKUP_CODE = " + name + "_CODE\n");
					sbSql1.append("   AND CTCC.ID = '" + cid + "') AS " + name + ",\n");
					sbSql.append(sbSql1.toString());
					sbSql.append(name + "_CODE,\n");
				} else if ("3".equals(dropddownType)) {
					sbSql.append(name + ",\n");
					sbSql.append(name + "_ID,\n");
				} else {
					if ("date".equals(type)) {
						sbSql.append("TO_CHAR(" + name + ",'yyyy-MM-dd') AS " + name + ",\n");
					} else {
						sbSql.append(name + ",\n");
					}
				}
			}
		}
		sbSql.append("         (SELECT LOOKUP_NAME\n");
		sbSql.append("            FROM CBB_LOOKUP_V\n");
		sbSql.append("           WHERE LOOKUP_TYPE = 'LANTOP_ARCHIVE_TYPE'\n");
		sbSql.append("             AND LOOKUP_CODE = (SELECT ARCHIVE_TYPE\n");
		sbSql.append("                                  FROM LANTOP_ARCHIVE_CLASS\n");
		sbSql.append("                                 WHERE ID = LDV.LANTOP_NODE_ID)) AS ARCHIVE_NAME,\n");
		sbSql.append("         LDV.LANTOP_NODE_ID,\n");
		sbSql.append("         LDV.LANTOP_RCD_ID AS LANTOP_FJ_RCD_ID,\n");
		sbSql.append("         LDV.PARENT_ID,\n");
		sbSql.append("         LDV.PUBLISH_STATUS,\n");
		sbSql.append("         LDV.LANTOP_ARCHIVE_STATUS,\n");
		sbSql.append("         (SELECT ARCHIVE_CLASS_NODE_CODE\n");
		sbSql.append("            FROM LANTOP_ARCHIVE_CLASS\n");
		sbSql.append("           WHERE ARCHIVE_TYPE IS NOT NULL\n");
		sbSql.append("             AND ARCHIVE_TYPE NOT IN ('-1', '0', '10')\n");
		sbSql.append("          CONNECT BY PRIOR PARENT_ID = ID\n");
		sbSql.append("           START WITH ID = LDV.LANTOP_NODE_ID) AS ARCHIVE_CLASS_NODE_CODE,\n");
		sbSql.append("         (SELECT ARCHIVE_CLASS_NODE_NAME\n");
		sbSql.append("            FROM LANTOP_ARCHIVE_CLASS\n");
		sbSql.append("           WHERE ARCHIVE_TYPE IS NOT NULL\n");
		sbSql.append("             AND ARCHIVE_TYPE NOT IN ('-1', '0', '10')\n");
		sbSql.append("          CONNECT BY PRIOR PARENT_ID = ID\n");
		sbSql.append("           START WITH ID = LDV.LANTOP_NODE_ID) AS ARCHIVE_CLASS_NODE_NAME,\n");
		sbSql.append("         (SELECT LLAC.ARCHIVE_TYPE\n");
		sbSql.append("            FROM CBB_TAB_NODE TCTN\n");
		sbSql.append("            LEFT JOIN LANTOP_ARCHIVE_CLASS LLAC\n");
		sbSql.append("              ON LLAC.ID = TCTN.NODE_ID\n");
		sbSql.append("           WHERE TCTN.TABLE_ID = LDV.ARCHIVE_TABLE_ID\n");
		sbSql.append("             AND LLAC.ARCHIVE_TYPE IS NOT NULL) AS ARCHIVE_TYPE,\n");
		sbSql.append("         LDV.ARCHIVE_TABLE_ID,\n");
		sbSql.append("         (SELECT DECODE(SUBSTR(LDV.ARCHIVE_TABLE_NAME, -3, 3),\n");
		sbSql.append("                        'AJJ',\n");
		sbSql.append("                        'AJJ',\n");
		sbSql.append("                        'WJJ')\n");
		sbSql.append("            FROM CBB_TAB_NODE\n");
		sbSql.append("           WHERE TABLE_ID = LDV.ARCHIVE_TABLE_ID\n");
		sbSql.append("             AND NODE_ID = LANTOP_NODE_ID\n");
		sbSql.append("             AND ROWNUM <= 1) AS ARCHIVE_TABLE_LEVEL,\n");
		sbSql.append("         LDV.ARCHIVE_TABLE_TITLE,\n");
		sbSql.append("         LDV.ARCHIVE_TABLE_NAME,\n");
		sbSql.append("         LDV.LANTOP_RCD_ID,\n");
		sbSql.append("         (SELECT LOOKUP_NAME\n");
		sbSql.append("            FROM SYS_LOOKUP_V\n");
		sbSql.append("           WHERE LOOKUP_TYPE = 'CBB_SECRET'\n");
		sbSql.append("             AND LOOKUP_CODE = LDV.MJ_CODE) AS ARCHIVE_RCD_SECRET,\n");
		sbSql.append("         LDV.CREATION_DATE,\n");
		sbSql.append("         LDV.CREATED_BY,\n");
		sbSql.append("         LDV.ARCHIVE_MULTIMEDIA_TYPE,\n");
		sbSql.append("         LDV.QZH,\n");
		sbSql.append("         (SELECT COUNT(CDR.ATTACHMENT_ID)\n");
		sbSql.append("            FROM CBB_DOC_RELATION CDR\n");
		sbSql.append("           WHERE CDR.RECORD_ID = LDV.LANTOP_RCD_ID\n");
		sbSql.append("             AND CDR.IF_DELETE = 'N') AS QWS\n");
		sbSql.append("    FROM T1\n");
		
		if (dbUser != null && !"".equals(dbUser)) {
			sbSql.append("   INNER JOIN " + dbUser + "." + sysId + "_DATA_V_"+tempOrgCode+" LDV\n");
		} else {
			sbSql.append("   INNER JOIN "+ sysId + "_DATA_V_"+tempOrgCode+" LDV\n");
		}
		sbSql.append("      ON T1.RECORD_ID = LDV." + sysId + "_RCD_ID WHERE LANTOP_ARCHIVE_STATUS='3' OR LANTOP_ARCHIVE_STATUS='4' )\n");
		sbSql.append("SELECT T2.* FROM T2 WHERE 1 = 1 ");*/
		if ((pageNo!=null&&!"".equals(pageNo)||(otherFlag.equals("档案编研")))&&!"1".equals(ztby)){
			if (param.get("mysc")!=null&&"1".equals(param.get("mysc"))){
				//我的收藏
				sbSql.append(" SELECT V1.*,V1.LANTOP_RCD_ID RECORD_ID,T1.RELATION_ID  FROM "+ sysId + "_DATA_V_"+tempOrgCode+" V1 INNER JOIN T1 ON V1.LANTOP_RCD_ID=T1.RECORD_ID WHERE LANTOP_ARCHIVE_STATUS='3' OR LANTOP_ARCHIVE_STATUS='4'");
			}else {
				sbSql.append(" SELECT V1.*,V1.LANTOP_RCD_ID RECORD_ID FROM "+ sysId + "_DATA_V_"+tempOrgCode+" V1 INNER JOIN T1 ON V1.LANTOP_RCD_ID=T1.RECORD_ID WHERE LANTOP_ARCHIVE_STATUS='3' OR LANTOP_ARCHIVE_STATUS='4'");
			}
		}else {
			sbSql.append(" SELECT V1.*,T1.NUMCOUNT,T1.ID,V1.LANTOP_RCD_ID RECORD_ID  FROM "+ sysId + "_DATA_V_"+tempOrgCode+" V1 INNER JOIN T1 ON V1.LANTOP_RCD_ID=T1.RECORD_ID WHERE LANTOP_ARCHIVE_STATUS='3' OR LANTOP_ARCHIVE_STATUS='4'");
		}
		if (!"".equals(searchSql)) {
			sbSql.append(searchSql);
		}
		String sbSqlStr = sbSql.toString();

		// 构造PAGE对象
		String sqlPage = "";
		String sqlCount = "SELECT COUNT(1) AS COUNT FROM (" + sbSqlStr + ")";
		long count = 0;
		List<Map<String, Object>> listCount = jdbcAvicit.queryForMap(sqlCount, null);
		count = Integer.parseInt(String.valueOf(listCount.get(0).get("COUNT")));
		if (!"".equals(pageNo) && !"".equals(pageSize)&&!"1".equals(ztby)) {
			Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
			page.setPageSize(ComUtil.getPageSize(pageSize));
			page.setPageNo(ComUtil.getPageNo(pageNo));
			Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());

			int firstResult = pageBean.getFirstEntityIndex();
			int maxResults = pageBean.getRows();
			if (firstResult <= 0) {
				sqlPage = "select * from ( " + sbSqlStr + " ) where rownum <= " + maxResults;
			} else {
				sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + sbSqlStr + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
			}
		} else {
			sqlPage = sbSqlStr;
			Long page = Long.parseLong(pageNo);
			Long rows = Long.parseLong(pageSize);

			sqlPage = "SELECT\n" +
					"\t* \n" +
					"FROM\n" +
					"\t(\n" +
					"\tSELECT\n" +
					"\t\t* \n" +
					"\tFROM\n" +
					"\t\t(\n" +
					"\t\tSELECT\n" +
					"\t\t\tT.*,\n" +
					"\t\t\tROWNUM ROW1 \n" +
					"\t\tFROM\n" +
					"\t\t\t( "+sbSqlStr+" ORDER BY cast( NUMCOUNT AS int ) ASC ) T \n" +
					"\t\t) T1 \n" +
					"\tWHERE\n" +
					"\t\tT1.ROW1 > " + (page - 1) * rows + " \n" +
					"\t) T2 \n" +
					"WHERE\n" +
					"\tT2.ROW1 < " + (page * rows + 1);
		}
		List<Map<String, Object>> listSqlDatas = jdbcAvicit.queryForMap(sqlPage, null);
		if (listSqlDatas != null && listSqlDatas.size() > 0) {
			Map<String, Object> mapCount = new HashMap<String, Object>();
			mapCount = listSqlDatas.get(0);
			mapCount.put("ROW_COUNT", count);
		}
		if (listSqlDatas == null || listSqlDatas.size() == 0) {
			listSqlDatas = new ArrayList<Map<String, Object>>();
		}
		if (null != commTableSysFieldLoader.getAttachmentClassName() && !"".equals(commTableSysFieldLoader.getAttachmentClassName())) {
			this.fileUploadIntfsService.getAttachClassification(listSqlDatas);
		}
		return listSqlDatas;
	}

	/*------------------------------------20150120新增-------------------------------------------------*/
	/**
	 * 根据表ID，字段名，查询条件(SQL语句)查询
	 *
	 * @author 朱锋
	 * @param tableId
	 * @param searchSql
	 * @param colName
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param flag
	 *            （SUM：求和 MAX：求最大值 MIN：求最小值 AVG:求平均值 COUNT:求条数）
	 * @return
	 * @throws Exception
	 *             Object
	 * @throws
	 */
	@Override
	public Object getOperationTableColDataByIntfs(String tableId, String searchSql, String colName, String orgId, String deptId, String sysId, String flag) throws Exception {
		Object value = null;
		// 拼写SQL
		CbbTables cbbTables = getCbbTablesById(tableId);
		String tableName = cbbTables.getTableName();
		StringBuffer sbSql = new StringBuffer();
		flag = flag.toUpperCase();
		if ("SUM".equals(flag)) {
			sbSql.append("SELECT SUM(" + colName + ") AS VALUE FROM " + tableName + " WHERE 1=1");
		} else if ("MAX".equals(flag)) {
			sbSql.append("SELECT MAX(" + colName + ") AS VALUE FROM " + tableName + " WHERE 1=1");
		} else if ("MIN".equals(flag)) {
			sbSql.append("SELECT MIN(" + colName + ") AS VALUE FROM " + tableName + " WHERE 1=1");
		} else if ("AVG".equals(flag)) {
			sbSql.append("SELECT AVG(" + colName + ") AS VALUE FROM " + tableName + " WHERE 1=1");
		} else if ("COUNT".equals(flag)) {
			sbSql.append("SELECT COUNT(" + colName + ") AS VALUE FROM " + tableName + " WHERE 1=1");
		} else if("OVERMAX".equals(flag)){ 
			//zcl 2019-09-03 添加查询类型 标识整理归档与档案整理导入查询最大保管号  因保管号不一定都是数字，所以只查询数字最大的保管号
			sbSql.append("SELECT MAX(" + colName + ") AS VALUE FROM (SELECT CAST(" + colName + " as int) as " + colName + " FROM " + tableName + " WHERE 1=1 " + searchSql + " and regexp_like(" + colName + ", '^[0-9]')) WHERE 1=1");
			searchSql = "";
		}
		// 添加条件
		if (!"".equals(searchSql)) {
			sbSql.append(searchSql);
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			rs = statement.executeQuery(sbSql.toString());
			while (rs.next()) {
				value = rs.getObject("VALUE");
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return value;
	}

	/*------------------------------------20150129新增-------------------------------------------------*/
	/**
	 * 根据SQL修改数据
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param sql
	 * @param params
	 * @throws Exception void
	 * @throws
	 */
	@Override
	public void updateRecordBySqlByIntfs(String orgId, String deptId, String sysId, String sql, Map<String, Object> params) throws Exception {
		// JDBC实现更新
		String modleName = "XXX模块";
		if (params.containsKey("modleName")) {
			modleName = (String) params.get("modleName");
		}
		executeJdbc(sysId, sql, "update", orgId, deptId, modleName);
	}

	/*------------------------------------20150204新增-------------------------------------------------*/
	/**
	 * 根据表IDS(以英文分号分开,顺序为：主;子)及查询条件， 获取2层表结构（主-子）的列信息以及数据
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableIds
	 * @param relationT1
	 * @param relationT2
	 * @param pageNo
	 * @param pageSize
	 * @param serachSql
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasByTwoTrendsTablesByIntfs(String orgId, String deptId, String sysId, String tableIds, String relationT1, String relationT2, String pageNo, String pageSize, String serachSql) throws Exception {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		List<CbbTabColumns> formShowList = new ArrayList<CbbTabColumns>();
		String[] ids = tableIds.split(";");
		String tableId1 = ids[0];
		String tableId2 = ids[1];
		StringBuffer sb = new StringBuffer();
		if (ids.length != 0) {
			CbbTables cbbTablesT1 = getCbbTablesById(tableId1);
			CbbTables cbbTablesT2 = getCbbTablesById(tableId2);
			sb.append("SELECT ");
			// 封装字段信息 T1
			List<CbbTabColumns> formtListT1 = getFormShowTableList(tableId1, "", cbbTablesT1.getTableName(), "0", sysId, orgId, deptId, "");// 基本字段对象
			String tableName1 = cbbTablesT1.getTableName();
			String tableName2 = cbbTablesT2.getTableName();
			for (int j = 0; j < formtListT1.size(); j++) {
				CbbTabColumns cbbTabColumns = formtListT1.get(j);
				String colName = cbbTabColumns.getColName();
				String colAsName = "T1_" + colName;
				if (j == 0) {
					sb.append(" T1.");
					sb.append(colName);
					sb.append(" AS ");
					sb.append(colAsName);
					cbbTabColumns.setColName(colAsName);
					formShowList.add(cbbTabColumns);
				} else {
					sb.append(" ,T1.");
					sb.append(colName);
					sb.append(" AS ");
					sb.append(colAsName);
					cbbTabColumns.setColName(colAsName);
					formShowList.add(cbbTabColumns);
				}
			}
			// 封装字段信息 T2
			List<CbbTabColumns> formtListT2 = getFormShowTableList(tableId2, "", cbbTablesT2.getTableName(), "0", sysId, orgId, deptId, "");// 基本字段对象
			for (int j = 0; j < formtListT2.size(); j++) {
				CbbTabColumns cbbTabColumns = formtListT2.get(j);
				String colName = cbbTabColumns.getColName();
				String colAsName = colName;
				if (formtListT1.size() != 0) {
					sb.append(" ,T2.");
					sb.append(colName);
					sb.append(" AS ");
					sb.append(colAsName);
					cbbTabColumns.setColName(colAsName);
					formShowList.add(cbbTabColumns);
				} else {
					if (j == 0) {
						sb.append(" T2.");
						sb.append(colName);
						sb.append(" AS ");
						sb.append(colAsName);
						cbbTabColumns.setColName(colAsName);
						formShowList.add(cbbTabColumns);
					} else {
						sb.append(" ,T2.");
						sb.append(colName);
						sb.append(" AS ");
						sb.append(colAsName);
						cbbTabColumns.setColName(colAsName);
						formShowList.add(cbbTabColumns);
					}
				}
			}
			sb.append(" FROM " + tableName1);
			sb.append(" T1 LEFT JOIN ");
			sb.append(tableName2);
			sb.append(" T2 ON T2." + relationT2 + " = T1." + relationT1 + " WHERE 1=1 ");
			sb.append(serachSql);
			// T1表获取排序字段
			List<Map<String, Object>> sortlist1 = commTableManagerIntfsService.getColDataOrderByTableId(tableId1, sysId, orgId, deptId);
			for (int i = 0; i < sortlist1.size(); i++) {
				if (i == 0) {
					sb.append(" ORDER BY ");
				}
				Map<String, Object> sortMap = new HashMap<String, Object>();
				sortMap = sortlist1.get(i);
				String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
				String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
				// A-升序，D-降序
				if ("A".equals(sortCode)) {
					sortCode = " ASC";
				} else {
					sortCode = " DESC";
				}
				sb.append("T1_" + colName + sortCode + ",");
			}
			// T2表获取排序字段
			List<Map<String, Object>> sortlist2 = commTableManagerIntfsService.getColDataOrderByTableId(tableId2, sysId, orgId, deptId);
			for (int i = 0; i < sortlist2.size(); i++) {
				if (i == 0 && sortlist1.size() == 0) {
					sb.append(" ORDER BY ");
				}
				Map<String, Object> sortMap = new HashMap<String, Object>();
				sortMap = sortlist2.get(i);
				String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
				String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
				// A-升序，D-降序
				if ("A".equals(sortCode)) {
					sortCode = " ASC";
				} else {
					sortCode = " DESC";
				}
				sb.append(colName + sortCode + ",");
			}
			String allSql = "";
			if (sortlist1.size() != 0 || sortlist2.size() != 0) {
				allSql = sb.substring(0, sb.length() - 1);
			} else {
				allSql = sb.toString();
			}

			// add start by zyh 2015.06.15
			List<String> colIds = new ArrayList<String>();
			StringBuffer queryLookupSql = new StringBuffer();
			queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
			queryLookupSql.append(" WHERE T.COLUMN_ID IN (");
			// 获得存在通用代码列的列id
			for (int i = 0; i < formShowList.size(); i++) {
				CbbTabColumns ctcs = formShowList.get(i);
				if ("1".equals(ctcs.getColDropdownType()) || "2".equals(ctcs.getColDropdownType())) {
					queryLookupSql.append("'" + ctcs.getId() + "',");
					colIds.add(ctcs.getId());
				}
			}
			String querySql = "";
			if (queryLookupSql.toString().endsWith(",")) {
				querySql = queryLookupSql.substring(0, queryLookupSql.length() - 1) + ")";
			}
			// 查询出列中所需通用代码
			List<Map<String, Object>> lookupList = new ArrayList<Map<String, Object>>();
			if (colIds.size() > 0) {
				lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(querySql);
			}
			// 创建通用代码map便于赋值
			Map<String, Map<String, String>> lookupMapKeyValue = new HashMap<String, Map<String, String>>();
			for (int i = 0; i < colIds.size(); i++) {
				Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
				for (int j = 0; j < lookupList.size(); j++) {
					Map<String, Object> lookupMap = lookupList.get(j);
					if (colIds.get(i).equals(lookupMap.get("COLUMN_ID"))) {
						lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
					}
				}
				lookupMapKeyValue.put(colIds.get(i), lookupNameCodeMap);
			}
			// add end by zyh 2015.06.15

			// 构造PAGE对象
			String sqlPage = "";
			Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
			page.setPageSize(ComUtil.getPageSize(pageSize));
			page.setPageNo(ComUtil.getPageNo(pageNo));
			Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());
			String sqlCount = "select count(1) from (" + allSql + ")";
			long count = 0;
			int firstResult = pageBean.getFirstEntityIndex();
			int maxResults = pageBean.getRows();
			if (firstResult <= 0) {
				sqlPage = "select * from ( " + allSql + " ) where rownum <= " + maxResults;
			} else {
				sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + allSql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
			}
			// 连接池
			DBConnectionCustomManager connectionMan = null;
			String poolName = orgId + "_" + sysId;
			Connection conn = null;
			Statement statement = null;
			ResultSet rs = null;
			try {
				// 实例化连接池
				connectionMan = DBConnectionCustomManager.getInstance(poolName);
				// 获取连接
				conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
				statement = conn.createStatement();
				rs = statement.executeQuery(sqlCount);
				while (rs.next()) {
					count = rs.getLong(1);
				}
				rs = statement.executeQuery(sqlPage);
				int num = 0;
				while (rs.next()) {
					Map<String, Object> map = new HashMap<String, Object>();
					if (num == 0) {
						map.put("ROW_COUNT", count);
					}
					num++;
					// 循环基本字段进行赋值
					for (int i = 0; i < formShowList.size(); i++) {
						CbbTabColumns cbbTabColumns = formShowList.get(i);
						String cValue = "";// 具体的值
						String colName = cbbTabColumns.getColName();// 列名
						String colType = formShowList.get(i).getColType();// 列类型
						String colRuleName = formShowList.get(i).getColRuleName();// 列规则名称
						if ("string".equals(colType)) {
							cValue = rs.getString(colName);
						} else if ("integer".equals(colType)) {
							cValue = rs.getString(colName);
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("date".equals(colType)) {
							cValue = rs.getDate(colName) + "";
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("float".equals(colType)) {
							cValue = rs.getString(colName);
							cValue = "null".equals(cValue) ? "" : cValue;
						} else if ("clob".equals(colType)) {
							Clob clobInData = rs.getClob(colName);
							if (null != clobInData) {
								int clobLength = (int) clobInData.length();
								cValue = clobInData.getSubString(1, clobLength);
							}
						}
						if ("1".equals(formShowList.get(i).getColDropdownType()) || "2".equals(formShowList.get(i).getColDropdownType())) {
							// StringBuffer sbSql = new StringBuffer();
							// sbSql.append("SELECT T.LOOKUP_NAME\n");
							// sbSql.append("  FROM CBB_TAB_LOOKUP_V T\n");
							// sbSql.append(" WHERE T.COLUMN_ID = '"
							// + cbbTabColumns.getId() + "'\n");
							// sbSql.append("   AND T.LOOKUP_CODE = '" + cValue
							// + "'");
							// List<Object> listValue = hibernateDao
							// .findBySQL(sbSql.toString());
							// String codeName = "";
							// String codeCode = "";
							// if (listValue.size() != 0) {
							// codeName = String.valueOf(listValue.get(0));//
							// 获取该列该值所对应的通用代码名称
							// } else {
							// codeName = cValue;
							// }
							// codeCode = cValue;
							// map.put(colName, codeName);
							// map.put(colName + "_CODE", codeCode);

							// add start by zyh 2015.06.15
							Map<String, String> showLookupMap = lookupMapKeyValue.get(formShowList.get(i).getId());
							map.put(colName, showLookupMap.get(cValue) == null ? cValue : showLookupMap.get(cValue));
							map.put(colName + "_CODE", cValue);
							// add end by zyh 2015.06.15
						} else if ("user".equals(colRuleName)) {
							if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
								String[] users = cValue.split(",");
								String usersName = "";
								String usersId = "";
								for (int q = 0; q < users.length; q++) {
									if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
										SysUser su = userLoader.getSysUserById(users[q]);
										if (null != su) {
											usersName = usersName + su.getName() + ",";
											usersId = usersId + users[q] + ",";
										} else {
											usersName = usersName + users[q] + ",";
											usersId = usersId + users[q] + ",";
										}
										// usersName = usersName +
										// userLoader.getSysUserById(users[q]).getName()
										// + ",";
										// usersId = usersId + users[q] + ",";
									}
								}
								usersName = usersName.substring(0, usersName.length() - 1);
								usersId = usersId.substring(0, usersId.length() - 1);
								map.put(colName, usersName);
								map.put(colName + "_CODE", usersId);
							}
						} else if ("dept".equals(colRuleName)) {
							if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
								String[] depts = cValue.split(",");
								String deptName = "";
								String deptIds = "";
								for (int q = 0; q < depts.length; q++) {
									if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
										SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
										if (null != sdt) {
											deptName = deptName + sdt.getDeptName() + ",";
											deptIds = deptIds + depts[q] + ",";
										} else {
											deptName = deptName + depts[q] + ",";
											deptIds = deptIds + depts[q] + ",";
										}
										// deptName = deptName +
										// deptLoader.getSysDeptTl(depts[q],
										// "zh_CN").getDeptName() + ",";
										// deptIds = deptIds + depts[q] + ",";
									}
								}
								deptName = deptName.substring(0, deptName.length() - 1);
								deptIds = deptIds.substring(0, deptIds.length() - 1);
								map.put(colName, deptName);
								map.put(colName + "_CODE", deptIds);
							}
						} else if ("custom".equals(colRuleName)) {
							if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
								String path = cbbTabColumns.getCustomPath();// 获取自定义页面路径
								// 截取表名，字段值
								if (!"".equals(path) && null != path) {
									String[] url = path.split("[?]");
									if (url.length > 1) {
										String[] arg = url[1].split("&");// 表名，字段值字符串
										if (arg.length > 1) {
											String cNames = "";// 返回的显示值字符串
											String tName = arg[0].split("=")[1];// 表名
											String cName = arg[1].split("=")[1];// 列名
											StringBuffer sbSqlCustom = new StringBuffer();
											sbSqlCustom.append("SELECT T." + cName + "\n");
											sbSqlCustom.append("  FROM " + tName + " T\n");
											sbSqlCustom.append(" WHERE T.ID IN (");
											String[] datas = cValue.split(",");
											for (int d = 0; d < datas.length; d++) {
												if (d == datas.length - 1) {
													sbSqlCustom.append("'" + datas[d] + "'\n");
												} else {
													sbSqlCustom.append("'" + datas[d] + "',\n");
												}
											}
											sbSqlCustom.append(")");
											// JDBC实现
											// 查询列的值，并且给attribute02赋值
											Statement statements = null;
											ResultSet rss = null;
											try {
												statements = conn.createStatement();
												rss = statements.executeQuery(sbSqlCustom.toString());
												while (rss.next()) {
													cNames = cNames + rss.getString(cName) + ",";
												}
												if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
													cNames = cNames.substring(0, cNames.length() - 1);
												}
												map.put(colName, cNames);
											} catch (Exception e) {
												e.printStackTrace();
												throw new Exception("数据库操作异常，请联系管理员！");
											} finally {
												if (rss != null) {
													try {
														rss.close();
														rss = null;
													} catch (Exception e) {
														e.printStackTrace();
													}
												}
												if (statements != null) {
													try {
														statements.close();
														statements = null;
													} catch (Exception e) {
														e.printStackTrace();
													}
												}
											}
										}
									}
								}
							}
						} else {
							map.put(colName, cValue);
						}
					}
					map.put("ID", rs.getString("ID"));
					list.add(map);
				}
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				if (rs != null) {
					try {
						rs.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (statement != null) {
					try {
						statement.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (conn != null) {
					try {
						connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
		return list;
	}

	/*-------------------------------20150320新增方法--------------------------------------------------------*/
	/**
	 * 根据表ID以及查询条件，获取表的列信息以及数据（不转换任何数据，纯数据库数据）
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param pageNo
	 *            (如果为空字符串，那么不提供分页功能)
	 * @param pageSize
	 *            (如果为空字符串，那么不提供分页功能)
	 * @param serachCondition
	 * @param changeMap
	 *            (统一改变的值，字符串类型)
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasBySearchByNoChangeByIntfs(String orgId, String deptId, String sysId, String tableId, String pageNo, String pageSize, String serachCondition, Map<String, Object> changeMap) throws Exception {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		CbbTables cbbTables = getCbbTablesById(tableId);
		String sql = "SELECT * FROM " + cbbTables.getTableName() + " WHERE 1=1 ";
		if (!"".equals(serachCondition)) {
			sql = sql + serachCondition;
		}
		// 获取排序字段
		if (null != changeMap && changeMap.containsKey("searchOrder")) {
			LinkedHashMap<String, String> orderMap = (LinkedHashMap<String, String>) changeMap.get("searchOrder");
			if (orderMap.size() > 0) {
				// 取自定义排序
				int orderIndex = 0;
				Iterator orderIt = orderMap.keySet().iterator();
				while (orderIt.hasNext()) {
					String orderCol = String.valueOf(orderIt.next());// 排序字段英文名
					String orderRule = orderMap.get(orderCol);// 排序规则
					if (null != orderCol && !"".equals(orderCol) && !"null".equals(orderCol) && ("ASC".equals(orderRule) || "DESC".equals(orderRule))) {
						if (orderIndex == 0) {
							sql = sql + " ORDER BY " + orderCol + " " + orderRule + ",";
						} else {
							sql = sql + orderCol + " " + orderRule + ",";
						}
						orderIndex++;
					}
				}
			} else {
				// 默认取库结构配置排序
				List<Map<String, Object>> sortlist = commTableManagerIntfsService.getColDataOrderByTableId(tableId, sysId, orgId, deptId);
				for (int i = 0; i < sortlist.size(); i++) {
					if (i == 0) {
						sql = sql + " ORDER BY ";
					}
					Map<String, Object> sortMap = sortlist.get(i);
					String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
					String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
					// A-升序，D-降序
					if ("A".equals(sortCode)) {
						sortCode = " ASC";
					} else {
						sortCode = " DESC";
					}
					sql = sql + colName + sortCode + ",";
				}
				if (sortlist.size() > 0) {
					sql = sql.substring(0, sql.length() - 1);
				}
			}
		} else {
			// 默认取库结构配置排序
			List<Map<String, Object>> sortlist = commTableManagerIntfsService.getColDataOrderByTableId(tableId, sysId, orgId, deptId);
			for (int i = 0; i < sortlist.size(); i++) {
				if (i == 0) {
					sql = sql + " ORDER BY ";
				}
				Map<String, Object> sortMap = sortlist.get(i);
				String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
				String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
				// A-升序，D-降序
				if ("A".equals(sortCode)) {
					sortCode = " ASC";
				} else {
					sortCode = " DESC";
				}
				sql = sql + colName + sortCode + ",";
			}
			if (sortlist.size() > 0) {
				sql = sql.substring(0, sql.length() - 1);
			}
		}
		// 全部字段对象
		List<CbbTabColumns> formShowList = getFormShowTableList(tableId, "", cbbTables.getTableName(), "0", sysId, orgId, deptId, "");
		List<Map<String, String>> colList = new ArrayList<Map<String, String>>();
		for (int i = 0; i < formShowList.size(); i++) {
			String colType = formShowList.get(i).getColType();
			String colName = formShowList.get(i).getColName();// 列名
			Map<String, String> colMap = new HashMap<String, String>();
			colMap.put("colType", colType);
			colMap.put("colName", colName);
			colList.add(colMap);
		}
		// 构造PAGE对象
		String sqlPage = "";
		String sqlCount = "select count(1) from (" + sql + ")";
		long count = 0;
		if (!"".equals(pageNo) && !"".equals(pageSize)) {
			Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
			page.setPageSize(ComUtil.getPageSize(pageSize));
			page.setPageNo(ComUtil.getPageNo(pageNo));
			Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());
			int firstResult = pageBean.getFirstEntityIndex();
			int maxResults = pageBean.getRows();
			if (firstResult <= 0) {
				sqlPage = "select * from ( " + sql + " ) where rownum <= " + maxResults;
			} else {
				sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + sql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
			}
		} else {
			sqlPage = sql;
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			rs = statement.executeQuery(sqlCount);
			while (rs.next()) {
				count = rs.getLong(1);
			}
			rs = statement.executeQuery(sqlPage);
			int num = 0;
			Map<String, String> cMap = null;
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				if (num == 0 && !"".equals(pageNo) && !"".equals(pageSize)) {
					map.put("ROW_COUNT", count);
				}
				num++;

				for (int i = 0; i < colList.size(); i++) {
					cMap = colList.get(i);
					String cValue = "";
					String colName = cMap.get("colName");
					String colType = cMap.get("colType");
					if ("string".equals(colType)) {
						cValue = rs.getString(colName);
					} else if ("integer".equals(colType)) {
						cValue = rs.getString(colName);
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("date".equals(colType)) {
						cValue = rs.getDate(colName) + "";
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("float".equals(colType)) {
						cValue = rs.getString(colName);
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("clob".equals(colType)) {
						Clob clobInData = rs.getClob(colName);
						if (null != clobInData) {
							int clobLength = (int) clobInData.length();
							cValue = clobInData.getSubString(1, clobLength);
						}
					}
					Object cvalue = changeMap.get(colName);
					if (!"null".equals(cvalue) && cvalue != null) { // 如果 统一替换的MAP存在值那么替换它
						map.put(colName, changeMap.get(colName));
					} else {
						map.put(colName, cValue);
					}
				}
				map.put("ID", rs.getString("ID"));
				list.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return list;
	}

	/*--------------------------------------------------自建方法-------------------------------------------------------------------*/
	/**
	 * 根据CbbTablesId获取该表对象
	 *
	 * @author 朱锋
	 * @param id
	 * @return CbbTables
	 * @throws
	 */
	public CbbTables getCbbTablesById(String id) {
		CbbTables h = (CbbTables) hibernateDao.getSession().get(CbbTables.class, id);
		return h;
	}

	/**
	 * 用JDBC执行
	 *
	 * @param sysId
	 * @param sql
	 */
	public void executeJdbc(String sysId, String sql, String type, String orgId, String deptId, String modleName) throws Exception {
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			if (type.equals("insert")) {
				statement.execute(sql);
				SysLogUtil.log(modleName, "新增记录", OpType.insert, OpResult.success, LogBaseFactory.getLogBase());
			} else if (type.equals("update")) {
				statement.executeUpdate(sql);
				SysLogUtil.log(modleName, "更新记录", OpType.update, OpResult.success, LogBaseFactory.getLogBase());
			} else if (type.equals("delete")) {
				statement.executeUpdate(sql);
				SysLogUtil.log(modleName, "删除记录", OpType.delete, OpResult.success, LogBaseFactory.getLogBase());
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

	/**
	 * 获取基本基本字段对象集合
	 *
	 * @author 朱锋
	 * @param tableId
	 * @param id
	 * @param tableName
	 * @param flag
	 * @param sysId
	 * @return
	 * @throws Exception
	 *             List<CbbTabColumns>
	 * @throws
	 */
	public List<CbbTabColumns> getFormShowTableList(String tableId, String id, String tableName, String flag, String sysId, String orgId, String deptId, String nodeId) throws Exception {
		// flag 1-是否添加或编辑显示 2-是否列表显示 3-是否详细显示 4-是否查询显示 0-全部字段显示
		// 判断是否存在表单管理信息
		boolean flagform = false;
		StringBuffer sbSqls = new StringBuffer();
		sbSqls.append("SELECT COUNT(1)\n");
		sbSqls.append("  FROM CBB_TAB_FORM_CONFIG CTFC\n");
		sbSqls.append("  LEFT JOIN CBB_TAB_COLUMNS CTC\n");
		sbSqls.append("    ON CTC.ID = CTFC.COLUMN_ID\n");
		sbSqls.append(" WHERE CTC.TABLE_ID = '" + tableId + "'");
		List<Object> numList = hibernateDao.findBySQL(sbSqls.toString());
		int num = Integer.parseInt(String.valueOf(numList.get(0)));
		if (num > 0) {
			flagform = true;
		}
		StringBuffer sbSql = new StringBuffer();
		if (flagform && !"2".equals(flag) && !"0".equals(flag)) {
			// 存在表单配置
			sbSql.append("SELECT WW.*\n");
			sbSql.append("  FROM (SELECT T.COLUMN_ID\n");
			sbSql.append("          FROM (SELECT DISTINCT CTFC.COLUMN_ID,\n");
			sbSql.append("                                CTFC.ATTRIBUTE_11,\n");
			sbSql.append("                                CTC.COL_NAME\n");
			sbSql.append("                  FROM CBB_TAB_FORM_CONFIG CTFC\n");
			sbSql.append("                  LEFT JOIN CBB_TAB_COLUMNS CTC\n");
			sbSql.append("                    ON CTC.ID = CTFC.COLUMN_ID\n");
			sbSql.append("                 WHERE CTC.TABLE_ID = '" + tableId + "') T\n");
			sbSql.append("         ORDER BY T.ATTRIBUTE_11, T.COL_NAME) S\n");
			sbSql.append("  LEFT JOIN CBB_TAB_COLUMNS WW\n");
			sbSql.append("    ON WW.ID = S.COLUMN_ID"); 
		} else {
			// 不存在表单配置
			sbSql.append("SELECT T.*\n");
			sbSql.append("  FROM CBB_TAB_COLUMNS T\n");
			sbSql.append(" WHERE T.TABLE_ID = '" + tableId + "'\n");
			sbSql.append(" ORDER BY T.COL_ORDER,T.COL_NAME");
		}
		List<CbbTabColumns> cbbTabColumnsList = new ArrayList<CbbTabColumns>();
		List<Map<String, Object>> objList = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
		tableName = tableName.toUpperCase();
		String tabNodeId = "";
		List<Map<String, Object>> nodeRecordList = new ArrayList<Map<String, Object>>();
		if (null != nodeId && !"".equals(nodeId) && !"null".equals(nodeId)) {
			// 调用rest服务，查找节点著录定义配置信息，如果有配置信息，覆盖旧值
			tabNodeId = getCbbTabNodeIdByTableId(sysId, tableId, nodeId);
		}
		if (null != tabNodeId && !"".equals(tabNodeId) && !"null".equals(tabNodeId)) {
			nodeRecordList = getTabNodeRecordInfoByTabNodeId(tabNodeId);
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			for (int i = 0; i < objList.size(); i++) {
				Map<String, Object> colMap = objList.get(i);
				CbbTabColumns cbbTabColumns = new CbbTabColumns();
				String cid = String.valueOf(colMap.get("ID"));
				//将map对象转换为实体对象
				cbbTabColumns.setId(cid);
				cbbTabColumns.setTableId(String.valueOf(colMap.get("TABLE_ID")));
				cbbTabColumns.setColName(String.valueOf(colMap.get("COL_NAME")).toUpperCase());
				cbbTabColumns.setColLabel(String.valueOf(colMap.get("COL_LABEL")));
				cbbTabColumns.setColType(String.valueOf(colMap.get("COL_TYPE")));
				String colLengthstr = String.valueOf(colMap.get("COL_LENGTH"));
				if(null != colLengthstr && !"".equals(colLengthstr) && !"null".equals(colLengthstr)){
					BigDecimal colLength = new BigDecimal(colLengthstr);
					cbbTabColumns.setColLength(colLength);
				}
				String colDecimalstr = String.valueOf(colMap.get("COL_DECIMAL"));
				if(null != colDecimalstr && !"".equals(colDecimalstr) && !"null".equals(colDecimalstr)){
					BigDecimal colDecimal = new BigDecimal(Integer.parseInt(colDecimalstr));
					cbbTabColumns.setColDecimal(colDecimal);
				}
				cbbTabColumns.setColIsSys(String.valueOf(colMap.get("COL_IS_SYS")));
				BigDecimal colOrder = new BigDecimal(Integer.parseInt(String.valueOf(colMap.get("COL_ORDER"))));
				cbbTabColumns.setColOrder(colOrder);
				cbbTabColumns.setColIsMust(String.valueOf(colMap.get("COL_IS_MUST")));
				cbbTabColumns.setColIsVisible(String.valueOf(colMap.get("COL_IS_VISIBLE")));
				cbbTabColumns.setColIsSearch(String.valueOf(colMap.get("COL_IS_SEARCH")));
				cbbTabColumns.setColIsEdit(String.valueOf(colMap.get("COL_IS_EDIT")));
				cbbTabColumns.setColIsTabVisible(String.valueOf(colMap.get("COL_IS_TAB_VISIBLE")));
				cbbTabColumns.setColIsDetail(String.valueOf(colMap.get("COL_IS_DETAIL")));
				cbbTabColumns.setColDropdownType(String.valueOf(colMap.get("COL_DROPDOWN_TYPE")));
				cbbTabColumns.setColGeneMethod(String.valueOf(colMap.get("COL_GENE_METHOD")));
				cbbTabColumns.setColRuleName(String.valueOf(colMap.get("COL_RULE_NAME")));
				cbbTabColumns.setColRuleTitle(String.valueOf(colMap.get("COL_RULE_TITLE")));
				cbbTabColumns.setCustomPath(String.valueOf(colMap.get("CUSTOM_PATH")));
				cbbTabColumns.setRemark(String.valueOf(colMap.get("REMARK")));
				cbbTabColumns.setOrgId(String.valueOf(colMap.get("ORG_ID")));
				cbbTabColumns.setDeptId(String.valueOf(colMap.get("DEPT_ID")));
				cbbTabColumns.setSysId(String.valueOf(colMap.get("SYS_ID")));
				cbbTabColumns.setSecretLevel(String.valueOf(colMap.get("SECRET_LEVEL")));
				cbbTabColumns.setSysApplicationId(String.valueOf(colMap.get("SYS_APPLICATION_ID")));
				String lastUpdateDatestr = String.valueOf(colMap.get("LAST_UPDATE_DATE"));
				if(null != lastUpdateDatestr && !"".equals(lastUpdateDatestr) && !"null".equals(lastUpdateDatestr)){
					SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//注意月份是MM
					cbbTabColumns.setLastUpdateDate(simpleDateFormat.parse(lastUpdateDatestr));
				}
				cbbTabColumns.setLastUpdatedBy(String.valueOf(colMap.get("LAST_UPDATED_BY")));
				String creationDatestr = String.valueOf(colMap.get("CREATION_DATE"));
				if(null != creationDatestr && !"".equals(creationDatestr) && !"null".equals(creationDatestr)){
					SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//注意月份是MM
					cbbTabColumns.setCreationDate(simpleDateFormat.parse(creationDatestr));
				}
				cbbTabColumns.setCreatedBy(String.valueOf(colMap.get("CREATED_BY")));
				cbbTabColumns.setLastUpdateIp(String.valueOf(colMap.get("LAST_UPDATE_IP")));
				cbbTabColumns.setVersion(Long.parseLong(String.valueOf(colMap.get("VERSION"))));
				cbbTabColumns.setAttribute01(String.valueOf(colMap.get("ATTRIBUTE_01")));
				cbbTabColumns.setAttribute02(String.valueOf(colMap.get("ATTRIBUTE_02")));
				cbbTabColumns.setAttribute03(String.valueOf(colMap.get("ATTRIBUTE_03")));
				cbbTabColumns.setAttribute04(String.valueOf(colMap.get("ATTRIBUTE_04")));
				cbbTabColumns.setAttribute05(String.valueOf(colMap.get("ATTRIBUTE_05")));
				cbbTabColumns.setAttribute06(String.valueOf(colMap.get("ATTRIBUTE_06")));
				cbbTabColumns.setAttribute07(String.valueOf(colMap.get("ATTRIBUTE_07")));
				cbbTabColumns.setAttribute08(String.valueOf(colMap.get("ATTRIBUTE_08")));
				String attribute09str = String.valueOf(colMap.get("ATTRIBUTE_09"));
				if(null != attribute09str && !"".equals(attribute09str) && !"null".equals(attribute09str)){
					SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//注意月份是MM
					cbbTabColumns.setAttribute09(simpleDateFormat.parse(attribute09str));
				}
				String attribute10str = String.valueOf(colMap.get("ATTRIBUTE_10"));
				if(null != attribute10str && !"".equals(attribute10str) && !"null".equals(attribute10str)){
					SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//注意月份是MM
					cbbTabColumns.setAttribute10(simpleDateFormat.parse(attribute10str));
				}
				String attribute11str = String.valueOf(colMap.get("ATTRIBUTE_11"));
				if(null != attribute11str && !"".equals(attribute11str) && !"null".equals(attribute11str)){
					BigDecimal attribute11 = new BigDecimal(Integer.parseInt(attribute11str));
					cbbTabColumns.setAttribute11(attribute11);
				}
				String attribute12str = String.valueOf(colMap.get("ATTRIBUTE_12"));
				if(null != attribute12str && !"".equals(attribute12str) && !"null".equals(attribute12str)){
					BigDecimal attribute12 = new BigDecimal(attribute12str);
					cbbTabColumns.setAttribute12(attribute12);
				}
				String attribute13str = String.valueOf(colMap.get("ATTRIBUTE_13"));
				if(null != attribute13str && !"".equals(attribute13str) && !"null".equals(attribute13str)){
					BigDecimal attribute13 = new BigDecimal(attribute13str);
					cbbTabColumns.setAttribute13(attribute13);
				}
				String attribute14str = String.valueOf(colMap.get("ATTRIBUTE_14"));
				if(null != attribute14str && !"".equals(attribute14str) && !"null".equals(attribute14str)){
					BigDecimal attribute14 = new BigDecimal(attribute14str);
					cbbTabColumns.setAttribute14(attribute14);
				}
				String attribute15str = String.valueOf(colMap.get("ATTRIBUTE_15"));
				if(null != attribute15str && !"".equals(attribute15str) && !"null".equals(attribute15str)){
					BigDecimal attribute15 = new BigDecimal(attribute15str);
					cbbTabColumns.setAttribute15(attribute15);
				}
				cbbTabColumns.setColShowFormat(String.valueOf(colMap.get("COL_SHOW_FORMAT")));
				cbbTabColumns.setColGeneMethodRule(String.valueOf(colMap.get("COL_GENE_METHOD_RULE")));
				cbbTabColumns.setColIsDisplay(String.valueOf(colMap.get("COL_IS_DISPLAY")));
				cbbTabColumns.setColIsComplement(String.valueOf(colMap.get("COL_IS_COMPLEMENT")));
				cbbTabColumns.setColComplementNum(String.valueOf(colMap.get("COL_COMPLEMENT_NUM")));
				cbbTabColumns.setColGeneMethodRuleText(String.valueOf(colMap.get("COL_GENE_METHOD_RULE_TEXT")));
				if (nodeRecordList != null && nodeRecordList.size() > 0) {
					for (Map<String, Object> nodeRecordMap : nodeRecordList) {
						String colId = (String) nodeRecordMap.get("COLUMN_ID");
						String isVisible = (String) nodeRecordMap.get("COL_IS_VISIBLE");
						String isTabVisible = (String) nodeRecordMap.get("COL_IS_TAB_VISIBLE");
						String isDetail = (String) nodeRecordMap.get("COL_IS_DETAIL");
						String isSearch = (String) nodeRecordMap.get("COL_IS_SEARCH");
						if (cid.equals(colId)) {
							cbbTabColumns.setColIsVisible(isVisible);
							cbbTabColumns.setColIsTabVisible(isTabVisible);
							cbbTabColumns.setColIsDetail(isDetail);
							cbbTabColumns.setColIsSearch(isSearch);
						}
					}
				}
				// 根据ID，COLNAME去实体表中查询该字段的数据信息，供前台使用
				String cdata = "";// 数据字符串
				if (!"".equals(id)) {
					String colName = cbbTabColumns.getColName().toUpperCase();
					String colRuleName = cbbTabColumns.getColRuleName();
					StringBuffer sbSqlCol = new StringBuffer();
					// 类型为选择的特殊字段进行ID和NAME的转换
					if ("user".equals(colRuleName) || "dept".equals(colRuleName) || "custom".equals(colRuleName)) {
						cbbTabColumns.setIsCommField("N");
						sbSqlCol.append("SELECT " + colName + " FROM " + tableName);
					} else {
						cbbTabColumns.setIsCommField("N");
						sbSqlCol.append("SELECT " + colName + " FROM " + tableName);
					}
					sbSqlCol.append(" WHERE ID = '" + id + "'");
					rs = statement.executeQuery(sbSqlCol.toString());
					if ("user".equals(colRuleName) || "dept".equals(colRuleName) || "custom".equals(colRuleName)) {
						while (rs.next()) {
							if (!"".equals(rs.getString(colName)) && !"null".equals(rs.getString(colName)) && null != rs.getString(colName)) {
								cdata = cdata + rs.getString(colName) + ",";
							}
						}
					} else {
						while (rs.next()) {
							if (!"".equals(rs.getString(colName)) && !"null".equals(rs.getString(colName)) && null != rs.getString(colName)) {
								cdata = cdata + rs.getString(colName) + ",";
							}
						}
					}

					if (!"".equals(cdata)) {
						cdata = cdata.substring(0, cdata.length() - 1);
					}
					// 给colValueName字段充数据值----user&&dept&&custom
					if ("user".equals(colRuleName)) {
						if (!"".equals(cdata) && null != cdata && !"null".equals(cdata)) {
							String[] users = cdata.split(",");
							String usersName = "";
							for (int q = 0; q < users.length; q++) {
								if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
									SysUser su = userLoader.getSysUserById(users[q]);
									if (null != su) {
										usersName = usersName + su.getName() + ",";
									} else {
										usersName = usersName + users[q] + ",";
									}
								}
							}
							if (!"".equals(usersName)) {
								usersName = usersName.substring(0, usersName.length() - 1);
							}
							/**** 2015/07/24增加 - 郭亮 （配置统计生成时根据配置信息计算后的值不在原数据源中） *****/
							if (!"".equals(usersName)) {
								cbbTabColumns.setColValueName(usersName);
							} else {
								cbbTabColumns.setColValueName(cdata);
							}
							/**** 2015/07/24增加 - 郭亮 （配置统计生成时根据配置信息计算后的值不在原数据源中） *****/
						} else {
							String colSql = "SELECT " + colName + " FROM " + tableName + " WHERE ID = '" + id + "'";
							rs = statement.executeQuery(colSql);
							while (rs.next()) {
								String colValue = rs.getString(colName);
								cbbTabColumns.setColValueName(colValue);
							}
						}
					} else if ("dept".equals(colRuleName)) {
						if (!"".equals(cdata) && null != cdata && !"null".equals(cdata)) {
							String[] depts = cdata.split(",");
							String deptName = "";
							for (int q = 0; q < depts.length; q++) {
								if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
									SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
									if (null != sdt) {
										deptName = deptName + sdt.getDeptName() + ",";
									} else {
										deptName = deptName + depts[q] + ",";
									}
									// deptName = deptName +
									// deptLoader.getSysDeptTl(depts[q],
									// "zh_CN").getDeptName() + ",";
								}
							}
							if (!"".equals(deptName)) {
								deptName = deptName.substring(0, deptName.length() - 1);
							}
							/**** 2015/07/24增加 - 郭亮 （配置统计生成时根据配置信息计算后的值不在原数据源中） *****/
							if (!"".equals(deptName)) {
								cbbTabColumns.setColValueName(deptName);
							} else {
								cbbTabColumns.setColValueName(cdata);
							}
							/**** 2015/07/24增加 - 郭亮 （配置统计生成时根据配置信息计算后的值不在原数据源中） *****/
						}
					} else if ("custom".equals(colRuleName)) {
						if (!"".equals(cdata) && null != cdata && !"null".equals(cdata)) {
							String path = cbbTabColumns.getCustomPath();// 获取自定义页面路径
							// 截取表名，字段值
							if (!"".equals(path) && null != path) {
								String[] url = path.split("[?]");
								if (url.length > 1) {
									String[] arg = url[1].split("&");// 表名，字段值字符串
									if (arg.length > 1) {
										String cNames = "";// 返回的显示值字符串
										String tName = arg[0].split("=")[1];// 表名
										String cName = arg[1].split("=")[1];// 列名
										// JDBC实现
										// 查询列的值，并且给attribute02赋值
										statement = conn.createStatement();
										StringBuffer sbSqlCustom = new StringBuffer();
										sbSqlCustom.append("SELECT T." + cName + "\n");
										sbSqlCustom.append("  FROM " + tName + " T\n");
										sbSqlCustom.append(" WHERE T.ID IN (");
										String[] datas = cdata.split(",");
										for (int d = 0; d < datas.length; d++) {
											if (d == datas.length - 1) {
												sbSqlCustom.append("'" + datas[d] + "'\n");
											} else {
												sbSqlCustom.append("'" + datas[d] + "',\n");
											}
										}
										sbSqlCustom.append(")");
										ResultSet rss = null;
										Statement statements = null;
										try {
											statements = conn.createStatement();
											rss = statements.executeQuery(sbSqlCustom.toString());
											while (rss.next()) {
												cNames = cNames + rss.getString(cName) + ",";
											}
											if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
												cNames = cNames.substring(0, cNames.length() - 1);
											}
										} catch (Exception e) {
											e.printStackTrace();
										} finally {
											if (rss != null) {
												try {
													rss.close();
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
											if (statements != null) {
												try {
													statements.close();
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
										}
										/****
										 * 2015/07/24增加 - 郭亮
										 * （配置统计生成时根据配置信息计算后的值不在原数据源中）
										 *****/
										if (!"".equals(cNames)) {
											cbbTabColumns.setColValueName(cNames);
										} else {
											cbbTabColumns.setColValueName(cdata);
										}
										/****
										 * 2015/07/24增加 - 郭亮
										 * （配置统计生成时根据配置信息计算后的值不在原数据源中）
										 *****/
									}
								}
							}
						}
					}
				}
				// 给colValue字段充数据值
				cbbTabColumns.setColValue(cdata);
				if (cbbTabColumns.getColValueName() == null) {
					cbbTabColumns.setColValueName("");
				}
				if("0".equals(flag)){
					cbbTabColumnsList.add(cbbTabColumns);
				}else{
					String colIsDisplay = cbbTabColumns.getColIsDisplay();// 是否可见
					if("Y".equals(colIsDisplay)){
						if ("1".equals(flag)) {
							if ("Y".equals(cbbTabColumns.getColIsVisible())) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
						} else if ("2".equals(flag)) {
							if ("Y".equals(cbbTabColumns.getColIsTabVisible())) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
						} else if ("3".equals(flag)) {
							if ("Y".equals(cbbTabColumns.getColIsDetail())) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
						} else if ("4".equals(flag)) {
							if ("Y".equals(cbbTabColumns.getColIsSearch())) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
						}
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return cbbTabColumnsList;
	}

	/**
	 * 根据ColumnsId获取该表对象
	 *
	 * @author 朱锋
	 * @param id
	 * @return CbbTabColumns
	 * @throws
	 */
	public CbbTabColumns getCbbTabColumnsById(String id) {
		CbbTabColumns h = (CbbTabColumns) hibernateDao.getSession().get(CbbTabColumns.class, id);
		return h;
	}

	/*-------------------------------------20150324新增复制/剪切/粘贴-----------------------------------------------------------------*/
	/**
	 * 复制/剪切的粘贴操作
	 *
	 * @author 钟一华
	 * @param targetNodeId
	 *            目标节点id
	 * @param sourceNodeId
	 *            源节点id
	 * @param sourceTableId
	 *            源表tableid
	 * @param sourceChildTableId
	 *            源子表tableid
	 * @param fromType
	 *            类型(文件file/案卷an)
	 * @param dataIds
	 *            数据ids
	 * @param operator
	 *            复制/剪切操作(copy/cut)
	 * @param selectType
	 *            选择项(所选select/全选all)
	 * @param orgId
	 *            组织id
	 * @param deptId
	 *            部门id
	 * @param sysId
	 * @param loginUserId
	 * @param loginIp
	 * @param params
	 *            (sqlCondition: string查询sql语句 过路数据sql语句 childPaste:
	 *            string父id,用于子表数据粘贴到有父子关系的主表)
	 * @throws Exception
	 *             void
	 */
	@Override
	public void doPasteDatasByIntfs(String targetNodeId, String sourceNodeId, String sourceTableId, String sourceChildTableId, String fromType, String dataIds, String operator, String selectType, String orgId, String deptId, String sysId, String loginUserId, String loginIp,
									Map<String, Object> params) throws Exception {
		// 查询条件
		StringBuffer sb = new StringBuffer();
		// 获得所需复制的节点数据
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		// 数据id数组
		String[] ids = null;
		// 删除id集合
		List<String> deleteDataIds = new ArrayList<String>();
		// 判断复制或粘贴是否是所选操作
		if (null != selectType && "select".equals(selectType) && null != dataIds && !"".equals(dataIds)) {
			ids = dataIds.split(";");
			sb.append(" AND ID IN (");
			for (int i = 0; i < ids.length; i++) {
				deleteDataIds.add(ids[i]);
				sb.append("'" + ids[i] + "'");
				if (i != ids.length - 1) {
					sb.append(",");
				}
			}
			sb.append(")");
		} else {
			sb.append(" AND NODE_ID = '" + sourceNodeId + "'");
			String zlzt = (String) params.get("zlzt");
			if (null != zlzt && !"".equals(zlzt) && !"null".equals(zlzt)) {
				sb.append(" AND ZLZT= '" + zlzt + "'");
			}
			String sqlCondition = (String) params.get("sqlCondition");
			if (null != sqlCondition && !"".equals(sqlCondition)) {
				sb.append(sqlCondition);
			}
		}
		Map<String, Object> updateMap = new HashMap<String, Object>();
		String archiveShareStatus = (String) params.get("ARCHIVE_SHARE_STATUS");
		updateMap.put("NODE_ID", targetNodeId);
		updateMap.put("ARCHIVE_SHARE_STATUS", "0");
		if (null != archiveShareStatus && !"".equals(archiveShareStatus) && !"null".equals(archiveShareStatus)) {
			updateMap.put("ARCHIVE_SHARE_STATUS", archiveShareStatus);
		}
		updateMap.put("ARCHIVE_STATUS", "0");
		updateMap.put("ARCHIVE_FLOW_STATUS", "1");
		// 获得主表数据id
		String isChildPaste = String.valueOf(params.get("childPaste"));
		if (null != isChildPaste && !"null".equals(isChildPaste) && !"".equals(isChildPaste)) {
			updateMap.put("PARENT_ID", isChildPaste);
			sb.append(" AND PARENT_ID = '" + isChildPaste + "'");
		} else {
			updateMap.put("PARENT_ID", "");
		}
		list = this.getTableFieldsAndDatasBySearchByNoChangeByIntfs(orgId, deptId, sysId, sourceTableId, "", "", sb.toString(), updateMap);
		// 剪切时用到需要删除的ids
		// StringBuffer deleteIds = new StringBuffer();
		// 文件粘贴
		if ("file".equals(fromType)) {
			this.insertRecordByPasteBatchByIntfs(orgId, deptId, sysId, targetNodeId, sourceTableId, list, loginUserId, loginIp);
			// 剪切
			if ("cut".equals(operator)) {
				if (!"select".equals(selectType)) {
					for (int i = 0; i < list.size(); i++) {
						Map<String, Object> deleteMap = list.get(i);
						deleteDataIds.add((String) deleteMap.get("ID"));
					}
				}
				// 删除数据
				this.deleteRecordByBatchByIdsListByOnlyDatasByIntfs(orgId, deptId, sysId, sourceTableId, deleteDataIds);
				this.deleteAttachmentByDataIdsByIntfs(deleteDataIds, sysId);
			}
		} else if ("anFile".equals(fromType)) {
			// 获取当前案卷下文件的最大卷内序号
			Object obj = this.getOperationTableColDataByIntfs(sourceTableId, " AND PARENT_ID = '" + isChildPaste + "'", "ARCHIVE_IN_NUM", orgId, deptId, sysId, "MAX");
			long num = 0;
			if (null != obj) {
				num = Long.parseLong(String.valueOf(obj));
			}
			// 处理list的卷内序号，对粘贴的卷内序号进行自增
			for (int i = 0; i < list.size(); i++) {
				num++;
				Map<String, Object> map = list.get(i);
				map.put("ARCHIVE_IN_NUM", num);
			}
			this.insertRecordByPasteBatchByIntfs(orgId, deptId, sysId, targetNodeId, sourceTableId, list, loginUserId, loginIp);
			// 执行反更新案卷级操作 add by zyh 2018.09.04
			// 执行反更新操作
			Map<String, Object> updateParam = new HashMap<String, Object>();
			updateParam.put("modleName", "粘贴");
			this.updateAjDataByWjdataByInfs(sourceTableId, isChildPaste, orgId, deptId, sysId, targetNodeId, "", updateParam);
			// 剪切
			if ("cut".equals(operator)) {
				if (!"select".equals(selectType)) {
					for (int i = 0; i < list.size(); i++) {
						Map<String, Object> deleteMap = list.get(i);
						deleteDataIds.add((String) deleteMap.get("ID"));
					}
				}
				// 删除数据
				this.deleteRecordByBatchByIdsListByOnlyDatasByIntfs(orgId, deptId, sysId, sourceTableId, deleteDataIds);
				this.deleteAttachmentByDataIdsByIntfs(deleteDataIds, sysId);
			}
		} else {// 案卷粘贴
			// 子数据删除时用id集合
			List<String> deleteChildDataIds = new ArrayList<String>();
			CbbTables cts = this.getCbbTablesById(sourceTableId);
			StringBuffer selectChildSql = new StringBuffer();
			if ("select".equals(selectType)) {
				selectChildSql.append(" AND PARENT_ID IN (");
			} else {
				selectChildSql.append(" AND EXISTS (SELECT 1 FROM\n");
				selectChildSql.append(" (SELECT ID FROM " + cts.getTableName() + " WHERE 1 = 1 " + sb.toString() + ") B\n");
				selectChildSql.append(" WHERE PARENT_ID = B.ID AND NODE_ID = '" + sourceNodeId + "'");
			}
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> map = list.get(i);
				// 如果是剪切操作,则把需要剪切掉的数据id保存起来,复制后进行删除操作用
				if ("cut".equals(operator)) {
					if (!"select".equals(selectType)) {
						deleteDataIds.add((String) map.get("ID"));
					}
				}
				if ("select".equals(selectType)) {
					selectChildSql.append("'" + map.get("ID") + "'");
					if (i != list.size() - 1) {
						selectChildSql.append(",");
					}
				}
			}
			selectChildSql.append(") AND  ARCHIVE_STATUS='0' ");
			Map<String, Object> updateChildMap = new HashMap<String, Object>();
			updateChildMap.put("NODE_ID", targetNodeId);
			updateChildMap.put("ARCHIVE_SHARE_STATUS", "0");
			if (null != archiveShareStatus && !"".equals(archiveShareStatus) && !"null".equals(archiveShareStatus)) {
				updateChildMap.put("ARCHIVE_SHARE_STATUS", archiveShareStatus);
			}
			updateChildMap.put("ARCHIVE_STATUS", "0");
			updateChildMap.put("ARCHIVE_FLOW_STATUS", "1");
			List<Map<String, Object>> childList = this.getTableFieldsAndDatasBySearchByNoChangeByIntfs(orgId, deptId, sysId, sourceChildTableId, "", "", selectChildSql.toString(), updateChildMap);
			// 如果是剪切操作,则把需要剪切掉的数据id保存起来,复制后进行删除操作用
			if ("cut".equals(operator)) {
				for (int j = 0; j < childList.size(); j++) {
					Map<String, Object> childMap = childList.get(j);
					deleteChildDataIds.add((String) childMap.get("ID"));
				}
			}
			this.insertMainChildDatasByBatchByIntfs(orgId, deptId, sysId, targetNodeId, sourceTableId, sourceChildTableId, list, childList);
			// 如果是剪切操作,则删除源数据
			if ("cut".equals(operator)) {
				if (deleteDataIds.size() > 0) {
					this.deleteRecordByBatchByIdsListByOnlyDatasByIntfs(orgId, deptId, sysId, sourceTableId, deleteDataIds);
				}
				this.deleteAttachmentByDataIdsByIntfs(deleteDataIds, sysId);
				// 判断需要被删除的文件级数据
				if (deleteChildDataIds.size() > 0) {
					this.deleteRecordByBatchByIdsListByOnlyDatasByIntfs(orgId, deptId, sysId, sourceChildTableId, deleteChildDataIds);
				}
				this.deleteAttachmentByDataIdsByIntfs(deleteChildDataIds, sysId);
			}
		}
	}

	/**
	 * 主子表批量插入关系数据
	 *
	 * @author 钟一华
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param childTableId
	 * @param mainObjList
	 * @param childObjList
	 * @throws Exception
	 *             void
	 */
	@Override
	public void insertMainChildDatasByBatchByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, String childTableId, List<Map<String, Object>> mainObjList, List<Map<String, Object>> childObjList) throws Exception {
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		PreparedStatement ps = null;
		PreparedStatement psChild = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接

			conn.setAutoCommit(false);
			StringBuffer insertSql = new StringBuffer();
			if (mainObjList.size() > 0) {
				Map<String, Object> obj = mainObjList.get(0);
				CbbTables cbbTables = getCbbTablesById(tableId);
				// 序列字段
				Map<String, Object> parameter = new HashMap<String, Object>();
				parameter.put("TABLE_NAME", cbbTables.getTableName());
				parameter.put("COL_GENE_METHOD", "2");
				List<Map<String, Object>> xlColumnsList = commTableManagerIntfsService.getColumnsByParameter(parameter);
				// 获取序列字段最大值
				Map<String, Object> xlMap = new HashMap<String, Object>();
				for (int i = 0; i < xlColumnsList.size(); i++) {
					Map<String, Object> xlColumnsMap = xlColumnsList.get(i);
					String colName = (String) xlColumnsMap.get("COL_NAME");
					String value = "";
					String sql = "";
					if (null != nodeId && !"".equals(nodeId) && !"null".equals(nodeId)) {
						sql += " AND NODE_ID = '" + nodeId + "'";
					}
					String num = "";
					Object maxObj = this.getOperationTableColDataByIntfs(tableId, sql, colName, orgId, deptId, sysId, "MAX");
					if (null != maxObj) {
						num = maxObj.toString();
						int newNum = Integer.valueOf(num) + 1;
						num = newNum + "";
					} else {
						num = "1";
					}
					value = num;
					xlMap.put(colName, value);
				}
				insertSql.append("INSERT INTO " + cbbTables.getTableName() + "(");
				Iterator<String> iteratorColName = obj.keySet().iterator();
				int count = 0;
				Map<String, String> colTypeMap = new HashMap<String, String>();
				while (iteratorColName.hasNext()) {
					count++;
					String colName = String.valueOf(iteratorColName.next());
					String type = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
					colTypeMap.put(colName, type);
					if (!"ID".equals(colName.toUpperCase())) {
						insertSql.append(colName + ",");
					}
				}
				insertSql.append("ID) VALUES (");
				for (int i = 0; i < count - 1; i++) {
					insertSql.append("?,");
				}
				insertSql.append("?)");
				ps = conn.prepareStatement(insertSql.toString());
				List<Map<String, Object>> xlChildColumnsList = null;
				Map<String, Object> xlChildMap = new HashMap<String, Object>();
				Map<String, String> colTypeMapChild = new HashMap<String, String>();
				// 子表ps
				StringBuffer insertSqlChild = new StringBuffer();
				if (childObjList.size() > 0) {
					Map<String, Object> objChild = childObjList.get(0);
					CbbTables cbbTablesChild = getCbbTablesById(childTableId);
					parameter.put("TABLE_NAME", cbbTablesChild.getTableName());
					xlChildColumnsList = commTableManagerIntfsService.getColumnsByParameter(parameter);
					// 获取序列字段最大值
					/*由于显示数据库字段不对应，暂时注释
					for (int i = 0; i < xlChildColumnsList.size(); i++) {
						Map<String, Object> xlColumnsMap = xlChildColumnsList.get(i);
						String colName = (String) xlColumnsMap.get("COL_NAME");
						if (!"ARCHIVE_IN_NUM".equals(colName)) {
							String value = "";
							String sql = "";
							if (null != nodeId && !"".equals(nodeId) && !"null".equals(nodeId)) {
								sql += " AND NODE_ID = '" + nodeId + "'";
							}
							String num = "";
							Object maxObj = this.getOperationTableColDataByIntfs(childTableId, sql, colName, orgId, deptId, sysId, "MAX");
							if (null != maxObj) {
								num = maxObj.toString();
								int newNum = Integer.valueOf(num) + 1;
								num = newNum + "";
							} else {
								num = "1";
							}
							value = num;
							xlChildMap.put(colName, value);
						}
					}*/
					insertSqlChild.append("INSERT INTO " + cbbTablesChild.getTableName() + "(");
					Iterator<String> iteratorColNameChild = objChild.keySet().iterator();
					int countChild = 0;
					while (iteratorColNameChild.hasNext()) {
						countChild++;
						String colName = String.valueOf(iteratorColNameChild.next());
						String type = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, childTableId, colName);
						colTypeMapChild.put(colName, type);
						if (!"ID".equals(colName.toUpperCase())) {
							insertSqlChild.append(colName + ",");
						}
					}
					insertSqlChild.append("ID) VALUES (");
					for (int i = 0; i < countChild - 1; i++) {
						insertSqlChild.append("?,");
					}
					insertSqlChild.append("?)");
					psChild = conn.prepareStatement(insertSqlChild.toString());
				}

				Map<String, String> tempMap = new HashMap<String, String>();
				Map<String, Object> mapObj;
				Iterator<String> iterator;
				for (int i = 0; i < mainObjList.size(); i++) {
					mapObj = mainObjList.get(i);
					iterator = mapObj.keySet().iterator();
					int index = 1;
					String mainOldId = "";
					while (iterator.hasNext()) {
						String colName = String.valueOf(iterator.next());
						String value = String.valueOf(mapObj.get(colName));
						if (!"ID".equals(colName.toUpperCase())) {
							String colType = colTypeMap.get(colName);
							if ("string".equals(colType)) {
								if (value == null || "".equals(value) || "null".equals(value)) {
									ps.setString(index, "");
								} else {
									ps.setString(index, value);
								}
							} else if ("integer".equals(colType)) {
								if (value == null || "".equals(value) || "null".equals(value)) {
									boolean haveColumn = false;
									// 判断序列导入字段
									for (int k = 0; k < xlColumnsList.size(); k++) {
										Map<String, Object> columnsMap = xlColumnsList.get(k);
										String cName = (String) columnsMap.get("COL_NAME");
										if (cName.equals(colName)) {
											haveColumn = true;
											break;
										}
									}
									if (haveColumn) {
										long xlValue = Long.valueOf(xlMap.get(colName).toString());
										ps.setLong(index, xlValue);
										xlMap.put(colName, xlValue + 1);
									} else {
										ps.setNull(index, Types.INTEGER);
									}
								} else {
									ps.setLong(index, Long.valueOf(value));
								}
							} else if ("date".equals(colType)) {
								if (value == null || "".equals(value) || "null".equals(value)) {
									ps.setNull(index, Types.DATE);
								} else {
									if ("CREATION_DATE".equals(colName)){
										ps.setTimestamp(index, new Timestamp(System.currentTimeMillis()));
									}else {
										ps.setDate(index, Date.valueOf(value));
									}
								}
							} else if ("float".equals(colType)) {
								if (value == null || "".equals(value) || "null".equals(value)) {
									ps.setNull(index, Types.FLOAT);
								} else {
									ps.setFloat(index, Float.valueOf(value));
								}
							} else if ("blob".equals(colType)) {
								ps.setNull(index, Types.BLOB);
							} else if ("clob".equals(colType)) {
								if (value == null || "".equals(value) || "null".equals(value)) {
									ps.setNull(index, Types.CLOB);
								} else {
									ps.setString(index, value);
								}
							}
							index++;
						} else {
							mainOldId = value;
						}
					}
					String id = ComUtil.getId();
					String oldId = (String) mapObj.get("ID");
					tempMap.put(oldId, id);
					xlChildMap.put(oldId, 1);
					ps.setString(index, id);
					ps.addBatch();
					if (!"".equals(mainOldId)) {
						// // 存储数据库
						// if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "database".equals(SAVE_TYPE)) {
						// this.insertDataBaseAttachment(nodeId, tableId, mainOldId, id);
						// } else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "disk".equals(SAVE_TYPE)) {// 存储磁盘
						// this.insertDiskAttachment(nodeId, tableId, mainOldId, id);
						// } else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "fastdfs".equals(SAVE_TYPE)) {// 存储fastdfs
						// this.insertFastDfsAttachment(nodeId, tableId, mainOldId, id);
						// } else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "mongodb".equals(SAVE_TYPE)) {// 存储mongodb
						// this.insertMongoDbAttachment(nodeId, tableId, mainOldId, id);
						// } else {
						// this.insertMongoDbAttachment(nodeId, tableId, mainOldId, id);
						// }
						// 创建条目附件关系数据
						Map<String, Object> param = new HashMap<String, Object>();
						param.put("OLD_RECORD_ID", oldId);
						param.put("NEW_RECORD_ID", id);
						this.createAttachmentRelationDatas(param);
					}
					// if (i != 0 && i % 500 == 0) {
					// ps.executeBatch();
					// }
				}
				if (childObjList.size() > 0) {
					// 子表批量
					for (int i = 0; i < childObjList.size(); i++) {
						mapObj = childObjList.get(i);
						iterator = mapObj.keySet().iterator();
						String oldParentId = (String) mapObj.get("PARENT_ID");
						int index = 1;
						String childOldId = "";
						while (iterator.hasNext()) {
							String colName = String.valueOf(iterator.next());
							String value = String.valueOf(mapObj.get(colName));
							if ("PARENT_ID".equals(colName.toUpperCase())) {
								String newParentId = tempMap.get(value);
								psChild.setString(index, newParentId);
								index++;
							} else if (!"ID".equals(colName.toUpperCase()) && !"PARENT_ID".equals(colName.toUpperCase())) {
								String colType = colTypeMapChild.get(colName);
								if ("string".equals(colType)) {
									if (value == null || "".equals(value) || "null".equals(value)) {
										psChild.setString(index, "");
									} else {
										psChild.setString(index, value);
									}
								} else if ("integer".equals(colType)) {
									if (value == null || "".equals(value) || "null".equals(value)) {
										boolean haveColumn = false;
										// 判断序列导入字段
										for (int k = 0; k < xlChildColumnsList.size(); k++) {
											Map<String, Object> columnsMap = xlChildColumnsList.get(k);
											String cName = (String) columnsMap.get("COL_NAME");
											if (cName.equals(colName)) {
												haveColumn = true;
												break;
											}
										}
										if (haveColumn) {
											if ("ARCHIVE_IN_NUM".equals(colName)) {
												long xlValue = Long.valueOf(xlChildMap.get(oldParentId).toString());
												psChild.setLong(index, xlValue);
												xlChildMap.put(oldParentId, xlValue + 1);
											} else {
												long xlValue = Long.valueOf(xlChildMap.get(colName).toString());
												psChild.setLong(index, xlValue);
												xlChildMap.put(colName, xlValue + 1);
											}
										} else {
											psChild.setNull(index, Types.INTEGER);
										}
									} else {
										psChild.setLong(index, Long.valueOf(value));
									}
								} else if ("date".equals(colType)) {
									if (value == null || "".equals(value) || "null".equals(value)) {
										psChild.setNull(index, Types.DATE);
									} else {
										psChild.setDate(index, Date.valueOf(value));
									}
								} else if ("float".equals(colType)) {
									if (value == null || "".equals(value) || "null".equals(value)) {
										psChild.setNull(index, Types.FLOAT);
									} else {
										psChild.setFloat(index, Float.valueOf(value));
									}
								} else if ("blob".equals(colType)) {
									psChild.setNull(index, Types.BLOB);
								} else if ("clob".equals(colType)) {
									if (value == null || "".equals(value) || "null".equals(value)) {
										psChild.setNull(index, Types.CLOB);
									} else {
										psChild.setString(index, value);
									}
								}
								index++;
							} else {
								childOldId = value;
							}
						}
						String id = ComUtil.getId();
						psChild.setString(index, id);
						psChild.addBatch();
						if (!"".equals(childOldId)) {
							// // 存储数据库
							// if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "database".equals(SAVE_TYPE)) {
							// this.insertDataBaseAttachment(nodeId, tableId, childOldId, id);
							// } else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "disk".equals(SAVE_TYPE)) {// 存储磁盘
							// this.insertDiskAttachment(nodeId, tableId, childOldId, id);
							// } else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "fastdfs".equals(SAVE_TYPE)) {// 存储fastdfs
							// this.insertFastDfsAttachment(nodeId, tableId, childOldId, id);
							// } else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "mongodb".equals(SAVE_TYPE)) {// 存储mongodb
							// this.insertMongoDbAttachment(nodeId, tableId, childOldId, id);
							// } else {
							// this.insertMongoDbAttachment(nodeId, tableId, childOldId, id);
							// }
							// 创建条目附件关系数据
							Map<String, Object> param = new HashMap<String, Object>();
							param.put("OLD_RECORD_ID", childOldId);
							param.put("NEW_RECORD_ID", id);
							this.createAttachmentRelationDatas(param);
						}
						// if (i != 0 && i % 500 == 0) {
						// psChild.executeBatch();
						// }
					}
					psChild.executeBatch();
					conn.commit();
				}
				ps.executeBatch();
				conn.commit();
			}
		} catch (Exception e) {
			conn.rollback();
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (ps != null) {
				try {
					ps.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					conn.setAutoCommit(true);
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

	/**
	 * 批量删除
	 *
	 * @author 钟一华
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param ids
	 * @throws Exception
	 *             void
	 */
	public void deleteRecordByBatchByIdsListByIntfs(String orgId, String deptId, String sysId, String tableId, List<String> ids) throws Exception {
		if (ids.size() > 0) {
			CbbTables cbbTables = this.getCbbTablesById(tableId);
			// 连接池
			DBConnectionCustomManager connectionMan = null;
			String poolName = orgId + "_" + sysId;
			Connection conn = null;
			PreparedStatement ps = null;
			try {
				// 实例化连接池
				connectionMan = DBConnectionCustomManager.getInstance(poolName);
				// 获取连接
				conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接

				conn.setAutoCommit(false);
				StringBuffer deleteSql = new StringBuffer();
				deleteSql.append("DELETE FROM " + cbbTables.getTableName() + " WHERE ID = ?");
				ps = conn.prepareStatement(deleteSql.toString());
				String recordIds = "";
				for (int i = 0; i < ids.size(); i++) {
					recordIds += ids.get(i) + ";";
					ps.setString(1, ids.get(i));
					ps.addBatch();
					// if (i != 0 && i % 500 == 0) {
					// ps.executeBatch();
					// }
				}
				ps.executeBatch();
				conn.commit();
				recordIds = recordIds.substring(0, recordIds.length() - 1);
				// 调用删除附件等关系表方法
				this.deleteAttachmentAndRelationAndMarkerById(recordIds);
			} catch (Exception e) {
				conn.rollback();
				e.printStackTrace();
				throw new Exception("数据库操作异常，请联系管理员！");
			} finally {
				if (ps != null) {
					try {
						ps.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (conn != null) {
					try {
						conn.setAutoCommit(true);
						connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
	}

	/**
	 * 批量删除
	 *
	 * @author 钟一华
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param ids
	 * @throws Exception
	 *             void
	 */
	public void deleteRecordByBatchByIdsListByOnlyDatasByIntfs(String orgId, String deptId, String sysId, String tableId, List<String> ids) throws Exception {
		if (ids.size() > 0) {
			CbbTables cbbTables = this.getCbbTablesById(tableId);
			// 连接池
			DBConnectionCustomManager connectionMan = null;
			String poolName = orgId + "_" + sysId;
			Connection conn = null;
			PreparedStatement ps = null;
			try {
				// 实例化连接池
				connectionMan = DBConnectionCustomManager.getInstance(poolName);
				// 获取连接
				conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接

				conn.setAutoCommit(false);
				StringBuffer deleteSql = new StringBuffer();
				deleteSql.append("DELETE FROM " + cbbTables.getTableName() + " WHERE ID = ?");
				ps = conn.prepareStatement(deleteSql.toString());
				String recordIds = "";
				for (int i = 0; i < ids.size(); i++) {
					recordIds += ids.get(i) + ";";
					ps.setString(1, ids.get(i));
					ps.addBatch();
					// if (i != 0 && i % 500 == 0) {
					// ps.executeBatch();
					// }
				}
				ps.executeBatch();
				conn.commit();
				recordIds = recordIds.substring(0, recordIds.length() - 1);
			} catch (Exception e) {
				conn.rollback();
				e.printStackTrace();
				throw new Exception("数据库操作异常，请联系管理员！");
			} finally {
				if (ps != null) {
					try {
						ps.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (conn != null) {
					try {
						conn.setAutoCommit(true);
						connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
	}

	/**
	 * 根据userId查找userName
	 *
	 * @author 朱锋
	 * @param id
	 * @return
	 * @throws Exception
	 *             String
	 * @throws
	 */
	@Override
	public String getUserNameById(String id) throws Exception {
		String names = "";
		if (!"".equals(id) && null != id) {
			String[] ids = id.split(",");
			for (int i = 0; i < ids.length; i++) {
				String sql = "SELECT T.NAME FROM SYS_USER T WHERE T.ID = '" + ids[i] + "'";
				List<String> nameList = this.hibernateDao.findBySQL(sql);
				if (nameList != null && nameList.size() > 0) {
					names = names + "," + nameList.get(0);
				}
			}
			if (!"".equals(names)) {
				names = names.substring(1, names.length());
			}
		}
		return names;
	}

	/**
	 * 根据deptId查找deptName
	 *
	 * @author 朱锋
	 * @param id
	 * @return
	 * @throws Exception
	 *             String
	 * @throws
	 */
	@Override
	public String getDeptNameById(String id) throws Exception {
		String names = "";
		if (!"".equals(id) && null != id) {
			String[] ids = id.split(",");
			for (int i = 0; i < ids.length; i++) {
				String sql = "SELECT T.DEPT_NAME FROM SYS_DEPT_V T WHERE T.ID = '" + ids[i] + "'";
				List<String> nameList = this.hibernateDao.findBySQL(sql);
				if (nameList != null && nameList.size() > 0) {
					names = names + "," + nameList.get(0);
				}
			}
			if (!"".equals(names)) {
				names = names.substring(1, names.length());
			}
		}
		return names;
	}

	/**
	 * 自定义页面，根据ID查询具体的值
	 *
	 * @author 朱锋
	 * @param code
	 * @param path
	 * @return
	 * @throws Exception
	 *             String
	 * @throws
	 */
	@Override
	public String getCustomValue(String value, String path) throws Exception {
		String name = "";
		if (null != path && !"".equals(path) && !"null".equals(path)) {
			String[] paths = path.split("\\?");
			if (paths.length == 2) {
				String[] param = paths[1].split("&");
				if (param.length == 3) {
					String tableName = param[0].split("=")[1];// 表名
					String columnName = param[1].split("=")[1];// 列名

					if (null != tableName && !"".equals(tableName) && !"null".equals(tableName) && null != columnName && !"".equals(columnName) && !"null".equals(columnName)) {
						StringBuffer sbSql = new StringBuffer();
						sbSql.append("SELECT " + columnName + " FROM " + tableName + " T WHERE T.ID = '" + value + "'");
						List<Object> nameList = hibernateDao.findBySQL(sbSql.toString());
						if (nameList.size() > 0) {
							name = String.valueOf(nameList.get(0));
						}
					}
				}
			}
		}
		return name;
	}

	/**
	 * 保管号自动补全四位
	 * @author 赵晓龙
	 * @return
	 */
	private String getBghStr(String bgh){
		int count = 4; // 补全位数
		int strLength = bgh.length();  // 获取字符串长度
		int lackCount = count - strLength; // 待补全位数
		String lackMsg = ""; // 待补全内容
		if(strLength>=count){  // 满足位数
			return bgh;
		}else {
			while (lackCount>0){
				lackMsg=lackMsg+"0";
				lackCount--;
			}
			lackMsg= lackMsg+bgh;
		}
		return lackMsg;
	}

	/***
	 * 字符串字段配置为序列时的方法
	 *
	 * @author 郭亮
	 * @param data
	 *            选中行数据的值
	 * @param config
	 *            步长
	 * @return String
	 * @throws
	 */

	public String stringConfig(String data, String config) throws Exception {
		String valueStr = "";
		if (null == config || "null".equals(config) || "".equals(config)) { // 步长为空时返回选中行数据的值
			return data;
		}
		if (null != data && !"null".equals(data) && !"".equals(data)) {
			char[] configChar = config.toCharArray();// 步长字符数组
			boolean configIsDigit = true;
			for (int i = 0; i < configChar.length; i++) {
				configIsDigit = Character.isDigit(configChar[i]);
				if (!configIsDigit) {
					break;// 步长不是数字，跳出循环
				}
			}
			if (!configIsDigit) { // 步长不是数字，步长 + 值
				valueStr = data + config;
			} else { // 步长是数字，进行运算
				// 截取出data字符串中的末尾数字位
				char[] dataChar = data.toCharArray();// 值字符数组
				boolean dataIsDigit = true;
				int dataIndex = dataChar.length;// 数字位标识
				for (int j = dataChar.length - 1; j >= 0; j--) {
					dataIsDigit = Character.isDigit(dataChar[j]);
					if (dataIsDigit) { // 是数字
						dataIndex = j;// 标识位更新
					} else {
						break;
					}
				}
				if (!dataIsDigit && dataIndex == dataChar.length) { // 值字符串末尾不包含数字
					valueStr = data + config;
				} else {
					// 截取值字符串的末尾数字位
					String dataNumStr = data.substring(dataIndex, data.length());
					int dataNum = Integer.parseInt(dataNumStr);
					int configNum = Integer.parseInt(config);
					int value = dataNum + configNum;
					valueStr = data.substring(0, dataIndex) + value;

				}
			}
		} else { // 不存在数据时返回‘1’
			valueStr = config+"";
		}
		valueStr = this.getBghStr(valueStr);
		return valueStr;
	}

	/**
	 * 复制数据专用（批量）
	 *
	 * @author 钟一华
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param listMapObj
	 * @throws Exception
	 * @throws
	 */
	@Override
	public void insertRecordByPasteBatchByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, List<Map<String, Object>> listMapObj, String loginUserId, String loginIp) throws Exception {
		// -----------------批量新增方法--------------
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		PreparedStatement ps = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			conn.setAutoCommit(false);
			StringBuffer insertSql = new StringBuffer();
			if (listMapObj.size() > 0) {
				Map<String, Object> obj = listMapObj.get(0);
				String parentId = (String) obj.get("PARENT_ID");
				CbbTables cbbTables = getCbbTablesById(tableId);
				// 序列字段
				Map<String, Object> parameter = new HashMap<String, Object>();
				parameter.put("TABLE_NAME", cbbTables.getTableName());
				parameter.put("COL_GENE_METHOD", "2");
				List<Map<String, Object>> xlColumnsList = commTableManagerIntfsService.getColumnsByParameter(parameter);
				// 获取序列字段最大值
				Map<String, Object> xlMap = new HashMap<String, Object>();
				for (int i = 0; i < xlColumnsList.size(); i++) {
					Map<String, Object> xlColumnsMap = xlColumnsList.get(i);
					String colName = (String) xlColumnsMap.get("COL_NAME");
					String value = "";
					// 判断是否有父数据
					if (null != parentId && !"".equals(parentId) && !"null".equals(parentId) && "ARCHIVE_IN_NUM".equals(colName)) {
						String sql = " AND PARENT_ID = '" + parentId + "'";
						String num = "";
						Object maxObj = this.getOperationTableColDataByIntfs(tableId, sql, colName, orgId, deptId, sysId, "MAX");
						if (null != maxObj) {
							num = maxObj.toString();
							int newNum = Integer.valueOf(num) + 1;
							num = newNum + "";
						} else {
							num = "1";
						}
						value = num;
					} else {
						String sql = "";
						if (null != nodeId && !"".equals(nodeId) && !"null".equals(nodeId)) {
							sql += " AND NODE_ID = '" + nodeId + "'";
						}
						String num = "";
						Object maxObj = this.getOperationTableColDataByIntfs(tableId, sql, colName, orgId, deptId, sysId, "MAX");
						if (null != maxObj) {
							num = maxObj.toString();
							int newNum = Integer.valueOf(num) + 1;
							num = newNum + "";
						} else {
							num = "1";
						}
						value = num;
					}
					xlMap.put(colName, value);
				}
				insertSql.append("INSERT INTO " + cbbTables.getTableName() + "(");
				Iterator iteratorColName = obj.keySet().iterator();
				int count = 0;
				Map<String, String> colTypeMap = new HashMap<String, String>();
				while (iteratorColName.hasNext()) {
					count++;
					String colName = String.valueOf(iteratorColName.next());
					String type = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
					colTypeMap.put(colName, type);
					if (!"ID".equals(colName.toUpperCase())) {
						insertSql.append(colName + ",");
					}
				}
				insertSql.append("ID) VALUES (");
				for (int i = 0; i < count - 1; i++) {
					insertSql.append("?,");
				}
				insertSql.append("?)");
				ps = conn.prepareStatement(insertSql.toString());
				Map<String, Object> mapObj;
				Iterator iterator;
				for (int i = 0; i < listMapObj.size(); i++) {
					mapObj = listMapObj.get(i);
					iterator = mapObj.keySet().iterator();
					int index = 1;
					String oldId = "";
					while (iterator.hasNext()) {
						String colName = String.valueOf(iterator.next());
						String value = String.valueOf(mapObj.get(colName));
						if (!"ID".equals(colName.toUpperCase())) {
							String colType = colTypeMap.get(colName);
							if ("string".equals(colType)) {
								if (value == null || "".equals(value) || "null".equals(value)) {
									ps.setString(index, "");
								} else {
									ps.setString(index, value);
								}
							} else if ("integer".equals(colType)) {
								if (value == null || "".equals(value) || "null".equals(value)) {
									boolean haveColumn = false;
									// 判断序列导入字段
									for (int k = 0; k < xlColumnsList.size(); k++) {
										Map<String, Object> columnsMap = xlColumnsList.get(k);
										String cName = (String) columnsMap.get("COL_NAME");
										if (cName.equals(colName)) {
											haveColumn = true;
											break;
										}
									}
									if (haveColumn) {
										long xlValue = Long.valueOf(xlMap.get(colName).toString());
										ps.setLong(index, xlValue);
										xlMap.put(colName, xlValue + 1);
									} else {
										ps.setNull(index, Types.INTEGER);
									}
								} else {
									ps.setLong(index, Long.valueOf(value));
								}
							} else if ("date".equals(colType)) {
								if (value == null || "".equals(value) || "null".equals(value)) {
									ps.setNull(index, Types.DATE);
								} else {
									if ("CREATION_DATE".equals(colName)){
										ps.setTimestamp(index, new Timestamp(System.currentTimeMillis()));
									}else {
										ps.setDate(index, Date.valueOf(value));
									}
								}
							} else if ("float".equals(colType)) {
								if (value == null || "".equals(value) || "null".equals(value)) {
									ps.setNull(index, Types.FLOAT);
								} else {
									ps.setFloat(index, Float.valueOf(value));
								}
							} else if ("blob".equals(colType)) {
								ps.setNull(index, Types.BLOB);
							} else if ("clob".equals(colType)) {
								if (value == null || "".equals(value) || "null".equals(value)) {
									ps.setNull(index, Types.CLOB);
								} else {
									ps.setString(index, value);
								}
							}
							index++;
						} else {
							oldId = value;
						}
					}
					String id = ComUtil.getId();
					ps.setString(index, id);
					ps.addBatch();
					if (!"".equals(oldId)) {
						// 创建条目附件关系数据
						Map<String, Object> param = new HashMap<String, Object>();
						param.put("OLD_RECORD_ID", oldId);
						param.put("NEW_RECORD_ID", id);
						this.createAttachmentRelationDatas(param);
						// // 存储数据库
						// if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "database".equals(SAVE_TYPE)) {
						// this.insertDataBaseAttachment(nodeId, tableId, oldId, id);
						// } else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "disk".equals(SAVE_TYPE)) {// 存储磁盘
						// this.insertDiskAttachment(nodeId, tableId, oldId, id);
						// } else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "fastdfs".equals(SAVE_TYPE)) {// 存储fastdfs
						// this.insertFastDfsAttachment(nodeId, tableId, oldId, id);
						// } else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "mongodb".equals(SAVE_TYPE)) {// 存储mongodb
						// this.insertMongoDbAttachment(nodeId, tableId, oldId, id);
						// } else {
						// this.insertMongoDbAttachment(nodeId, tableId, oldId, id);
						// }
					}
					// if (i != 0 && i % 500 == 0) {
					// ps.executeBatch();
					// }
				}
				ps.executeBatch();
				conn.commit();
			}
		} catch (NumberFormatException e) {
			conn.rollback();
			e.printStackTrace();
			throw new Exception("数据转换异常,请检查数据格式！");
		} catch (IllegalArgumentException e) {
			conn.rollback();
			e.printStackTrace();
			throw new Exception("数据转换异常,请检查数据格式！");
		} catch (Exception e) {
			conn.rollback();
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (ps != null) {
				try {
					ps.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					conn.setAutoCommit(true);
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

	/**
	 * 根据源条目id和新条目id复制附件信息
	 *
	 * @author 钟一华
	 * @param dataId
	 * @param dataNewId
	 * @throws Exception
	 *             void
	 */
	@Override
	public void insertMongoDbAttachment(String dataId, String dataNewId) throws Exception {
		List<SysFileUpload> listAtt = new ArrayList<SysFileUpload>();
		String hql = "from SysFileUpload where FILE_BUSINESS_ID = ? and ATTRIBUTE_10 = 'N'";
		listAtt = this.hibernateDao.find(hql, dataId);
		if (listAtt != null && listAtt.size() > 0) {
			for (int i = 0; i < listAtt.size(); i++) {
				SysFileUpload sa = listAtt.get(i);
				String attId = sa.getId();
				String fileName = sa.getFILE_NAME();
				String attNewId = ComUtil.getId();
				// 插入附件信息
				SysFileUpload sysFileUpload = new SysFileUpload();
				sysFileUpload.setId(attNewId);
				sysFileUpload.setFILE_NAME(fileName);
				sysFileUpload.setFILE_BUSINESS_ID(dataNewId);
				sysFileUpload.setFILE_BUSINESS_TABLE_NAME(sa.getFILE_BUSINESS_TABLE_NAME());
				sysFileUpload.setFILE_SIZE(sa.getFILE_SIZE());
				sysFileUpload.setFILE_TYPE(sa.getFILE_TYPE());
				sysFileUpload.setATTACH_CATEGORY(sa.getATTACH_CATEGORY());
				sysFileUpload.setSECRET_LEVEL(sa.getSECRET_LEVEL());
				sysFileUpload.setATTRIBUTE_10("N");
				sysFileUploadService.insertSysFileUpload(sysFileUpload);
				// 插入MongoDb
				InputStream in = null;
				in = mongoDBManager.getMongoDBController("LANTOP").getGridFSIOById(attId);
				// mongoDBManager.getMongoDBController("LANTOP").insertGridFS(in, fileName, attNewId);
				fileUploadEvent.afterSaveFileByOther(sysFileUpload, in, "LANTOP", sa.getSECRET_LEVEL());
			}
		}
	}

	/**
	 * 根据源条目id和新条目id复制附件信息(mongodb)
	 * @author 钟一华
	 * @param dataId
	 * @param dataNewId
	 * @throws Exception void
	 */
	public void insertMongoDbAttachment(String nodeId, String tableId, String dataId, String dataNewId) throws Exception {
		List<SysFileUpload> listAtt = new ArrayList<SysFileUpload>();
		String hql = "from SysFileUpload where FILE_BUSINESS_ID = ? and ATTRIBUTE_10 = 'N'";
		listAtt = this.hibernateDao.find(hql, dataId);
		if (listAtt != null && listAtt.size() > 0) {
			for (int i = 0; i < listAtt.size(); i++) {
				SysFileUpload sa = listAtt.get(i);
				String attId = sa.getId();
				String fileName = sa.getFILE_NAME();
				String attNewId = ComUtil.getId();
				// 插入附件信息
				SysFileUpload sysFileUpload = new SysFileUpload();
				sysFileUpload.setId(attNewId);
				sysFileUpload.setFILE_NAME(fileName);
				sysFileUpload.setFILE_BUSINESS_ID(dataNewId);
				sysFileUpload.setFILE_BUSINESS_TABLE_NAME(sa.getFILE_BUSINESS_TABLE_NAME());
				sysFileUpload.setFILE_SIZE(sa.getFILE_SIZE());
				sysFileUpload.setFILE_TYPE(sa.getFILE_TYPE());
				sysFileUpload.setATTACH_CATEGORY(sa.getATTACH_CATEGORY());
				sysFileUpload.setSECRET_LEVEL(sa.getSECRET_LEVEL());
				sysFileUpload.setATTRIBUTE_10("N");
				sysFileUploadService.insertSysFileUpload(sysFileUpload);
				// 插入MongoDb
				InputStream in = null;
				in = mongoDBManager.getMongoDBController("LANTOP").getGridFSIOById(attId);
				// mongoDBManager.getMongoDBController("LANTOP").insertGridFS(in, fileName, attNewId);
				fileUploadEvent.afterSaveFileByOther(sysFileUpload, in, "LANTOP", sa.getSECRET_LEVEL());
			}
		}
	}


	/**
	 * 创建新条目附件关系数据
	 * @param param
	 * @throws Exception void
	 * @throws
	 */
	@Override
	public void createAttachmentRelationDatas(Map<String, Object> param) throws Exception {
		String oldRecordId = (String) param.get("OLD_RECORD_ID");
		String newRecordId = (String) param.get("NEW_RECORD_ID");
		String tableId = (String) param.get("TABLE_ID");
		String hql = "from CbbDocRelation where recordId = ?";
		List<CbbDocRelation> relations = this.hibernateDao.find(hql, new Object[] {oldRecordId});
		for (int i = 0; i < relations.size(); i++) {
			CbbDocRelation relation = relations.get(i);
			this.hibernateDao.evict(relation);
			CbbDocRelation newRelation = new CbbDocRelation();
			PojoUtil.copyProperties(newRelation, relation);
			String newRaltionId = ComUtil.getId();
			newRelation.setId(newRaltionId);
			if (null != tableId && !"".equals(tableId) && !"null".equals(tableId)) {
				newRelation.setArchiveTableId(tableId);
			}
			newRelation.setRecordId(newRecordId);
			PojoUtil.setSysProperties(newRelation, OpType.insert);
			this.hibernateDao.save(newRelation);
		}
	}

	/**
	 * 归档接口批量新增数据(带附件)
	 *
	 * @author 钟一华
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param listMapObj
	 * @throws Exception
	 * @throws
	 */
	@Override
	public Map<String, Object> insertRecordByfileBatchByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, List<Map<String, Object>> listMapObj, String loginUserId, String loginIp) throws Exception {
		Map<String, Object> resList = new HashMap<String, Object>();// 返回的日志结果集，包括全文及条目日志
		List<Map<String, String>> qwresList = new ArrayList<Map<String, String>>();// 返回的全文日志结果集
		List<Map<String, String>> tmresList = new ArrayList<Map<String, String>>();// 返回的条目日志结果集
		// -----------------批量新增方法--------------
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		PreparedStatement ps = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			conn.setAutoCommit(false);
			StringBuffer insertSql = new StringBuffer();
			if (listMapObj.size() > 0) {
				Map<String, Object> obj = listMapObj.get(0);
				CbbTables cbbTables = getCbbTablesById(tableId);
				// 获取列信息,判断是否存在默认值字段, 如果不存在 则添加默认值字段
				Map<String, Object> searchMap = new HashMap<String, Object>();
				searchMap.put("TABLE_ID", tableId);// 表id
				searchMap.put("COL_GENE_METHOD", "1");// 生成规则code 1为默认值
				List<Map<String, Object>> columnsList = this.commTableManagerIntfsService.getColumnsByParam(searchMap);
				for (int i = 0; i < columnsList.size(); i++) {
					Map<String, Object> columns = columnsList.get(i);
					if (!obj.containsKey(columns.get("COL_NAME"))) {
						String colType = (String) columns.get("COL_TYPE");
						if ("date".equals(colType)) {
							obj.put((String) columns.get("COL_NAME"), DateFormat.getDateInstance().format(new java.util.Date()));
						} else {
							obj.put((String) columns.get("COL_NAME"), columns.get("COL_GENE_METHOD_RULE"));
						}
					}
				}
				insertSql.append("INSERT INTO " + cbbTables.getTableName() + "(");
				Iterator iteratorColName = obj.keySet().iterator();
				int count = 0;
				Map<String, String> colTypeMap = new HashMap<String, String>();
				while (iteratorColName.hasNext()) {
					String colName = String.valueOf(iteratorColName.next());
					String type = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
					colTypeMap.put(colName, type);
					if (!"ID".equals(colName.toUpperCase()) && !"ATTACHMENTS".equals(colName.toUpperCase())) {
						insertSql.append(colName + ",");
						count++;
					}
				}
				insertSql.append("ID,ORG_ID,DEPT_ID,SYS_ID) VALUES (");
				for (int i = 0; i < count - 1; i++) {
					insertSql.append("?,");
				}
				insertSql.append("?,?,?,?,?)");
				ps = conn.prepareStatement(insertSql.toString());
				// 获取所有附件集合，并去重
				List<Map<String, Object>> attachList = new ArrayList<Map<String, Object>>();
				for (int i = 0; i < listMapObj.size(); i++) {
					Map<String, Object> map = listMapObj.get(i);
					if (map.containsKey("ATTACHMENTS")) {
						String attachString = (String) map.get("ATTACHMENTS");
						JSONArray jsonArray = JSONArray.fromObject(attachString);
						List<Map<String, Object>> list = JSONArray.toList(jsonArray, new HashMap<String, Object>(), new JsonConfig());
						attachList.addAll(list);
					}
				}
				attachList = removeRepeatMapByKey(attachList, "attachmentId");
				Map<String, Object> mapObj;
				Iterator iterator;
				for (int i = 0; i < listMapObj.size(); i++) {
					mapObj = listMapObj.get(i);
					iterator = mapObj.keySet().iterator();
					int index = 1;
					String attachments = "";// 该条目的附件信息集合JSON串
					while (iterator.hasNext()) {
						String colName = String.valueOf(iterator.next());
						String value = String.valueOf(mapObj.get(colName));
						if (!"ID".equals(colName.toUpperCase())) {
							if ("ATTACHMENTS".equals(colName.toUpperCase())) {
								JSONArray jsonArray = JSONArray.fromObject(value);
								List<Map<String, Object>> list = JSONArray.toList(jsonArray, new HashMap<String, Object>(), new JsonConfig());
								// 计算相同附件条目引用过几次，如果未使用则生成需要保存的附件id
								for (int j = 0; j < list.size(); j++) {
									Map<String, Object> currentAttach = list.get(j);
									for (int k = 0; k < attachList.size(); k++) {
										Map<String, Object> attachMap = attachList.get(k);
										if (currentAttach.get("attachmentId").equals(attachMap.get("attachmentId"))) {
											if (attachMap.containsKey("useCount")) {
												int useCount = Integer.parseInt(attachMap.get("useCount").toString());
												useCount++;
												attachMap.put("useCount", useCount);
												currentAttach.put("useCount", useCount);
												currentAttach.put("attach_save_id", attachMap.get("attach_save_id"));
											} else {
												attachMap.put("useCount", 1);
												String saveId = ComUtil.getId();
												attachMap.put("attach_save_id", saveId);
												currentAttach.put("useCount", 1);
												currentAttach.put("attach_save_id", saveId);
											}
										}
									}
								}
								String jsonAttach = JSON.toJSONString(list);
								attachments = jsonAttach;
							} else {
								String colType = colTypeMap.get(colName);
								if ("string".equals(colType)) {
									if (value == null || "".equals(value) || "null".equals(value)) {
										ps.setString(index, "");
									} else {
										ps.setString(index, value);
									}
								} else if ("integer".equals(colType)) {
									if (value == null || "".equals(value) || "null".equals(value)) {
										ps.setNull(index, Types.INTEGER);
									} else {
										ps.setLong(index, Long.valueOf(value));
									}
								} else if ("date".equals(colType)) {
									if (value == null || "".equals(value) || "null".equals(value)) {
										ps.setNull(index, Types.DATE);
									} else {
										ps.setDate(index, Date.valueOf(value));
									}
								} else if ("float".equals(colType)) {
									if (value == null || "".equals(value) || "null".equals(value)) {
										ps.setNull(index, Types.FLOAT);
									} else {
										ps.setFloat(index, Float.valueOf(value));
									}
								} else if ("blob".equals(colType)) {
									ps.setNull(index, Types.BLOB);
								} else if ("clob".equals(colType)) {
									if (value == null || "".equals(value) || "null".equals(value)) {
										ps.setNull(index, Types.CLOB);
									} else {
										ps.setString(index, value);
									}
								}
								index++;
							}
						}
					}
					String id = ComUtil.getId();
					ps.setString(index, id);
					ps.setString(index + 1, orgId);
					ps.setString(index + 2, deptId);
					ps.setString(index + 3, sysId);
					// ps.setString(index + 4, "2");//共享状态 默认：0
					ps.addBatch();
					Map<String, String> tmm = new HashMap<String, String>();// 条目日志集合
					tmm.put("gdResult", "成功 ");
					tmm.put("discription", "");
					tmm.put("dataSrc", "OADATA");
					tmm.put("tableName", cbbTables.getTableName());
					tmm.put("nodeId", nodeId);
					tmm.put("id", id);
					if (!"".equals(attachments)) {
						List<Map<String, String>> qwResList = this.insertAttachmentByJson(sysId, attachments, id, cbbTables.getTableName(), orgId, deptId, tableId, nodeId, loginUserId, loginIp);
						int good = 0;
						for (int j = 0; j < qwResList.size(); j++) {
							Map<String, String> m = qwResList.get(j);
							if (m.get("flag").equals("0")) {
								good++;
							} else {
								String msg = m.get("gdResult");
								throw new Exception(msg);
							}
							qwresList.add(m);
						}
						tmm.put("documentCount", good + "");
					}
					tmresList.add(tmm);
				}
				ps.executeBatch();
				conn.commit();
			}
		} catch (NumberFormatException e) {
			e.printStackTrace();
			for (int i = 0; i < tmresList.size(); i++) {
				Map<String, String> ttmm = tmresList.get(i);
				ttmm.put("gdResult", "失败");
				ttmm.put("discription", "操作失败：数据转换异常,请检查数据格式！");
				ttmm.put("documentCount", "0");
			}
			for (int i = 0; i < qwresList.size(); i++) {
				Map<String, String> qwmm = qwresList.get(i);
				qwmm.put("gdResult", "失败");
				qwmm.put("discription", "操作失败：数据转换异常,请检查数据格式！");
			}
			resList.put("tmresList", tmresList);
			resList.put("qwresList", qwresList);
			return resList;

		} catch (IllegalArgumentException e) {
			e.printStackTrace();
			for (int i = 0; i < tmresList.size(); i++) {
				Map<String, String> ttmm = tmresList.get(i);
				ttmm.put("gdResult", "失败");
				ttmm.put("discription", "操作失败：参数异常,请检参数！");
				ttmm.put("documentCount", "0");
			}
			for (int i = 0; i < qwresList.size(); i++) {
				Map<String, String> qwmm = qwresList.get(i);
				qwmm.put("gdResult", "失败");
				qwmm.put("discription", "操作失败：参数异常,请检参数！");
			}
			resList.put("tmresList", tmresList);
			resList.put("qwresList", qwresList);
			return resList;
		} catch (Exception e) {
			e.printStackTrace();
			conn.rollback();
			for (int i = 0; i < tmresList.size(); i++) {
				Map<String, String> ttmm = tmresList.get(i);
				ttmm.put("gdResult", "失败");
				ttmm.put("discription", "操作失败：数据库操作异常，请联系管理员！");
				ttmm.put("documentCount", "0");
			}
			for (int i = 0; i < qwresList.size(); i++) {
				Map<String, String> qwmm = qwresList.get(i);
				qwmm.put("gdResult", "失败");
				qwmm.put("discription", "操作失败：数据库操作异常，请联系管理员！");
			}
			if (qwresList.size() < 1) {
				Map<String, String> qwmm = new HashMap<String, String>();
				qwmm.put("gdResult", e.getMessage());
				qwmm.put("flag", "1");
				qwresList.add(qwmm);
			}
			resList.put("tmresList", tmresList);
			resList.put("qwresList", qwresList);
			return resList;
		} finally {
			if (ps != null) {
				try {
					ps.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					conn.setAutoCommit(true);
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		resList.put("tmresList", tmresList);
		resList.put("qwresList", qwresList);
		return resList;
	}

	/**
	 * 读取临时文件夹文件,并且上传附件(OA归档接口用)
	 * @param attachments
	 * @param dataId
	 * @throws Exception void
	 * @throws
	 */
	public List<Map<String, String>> insertAttachmentByJson(String sysId, String attachments, String dataId, String tableName, String orgId, String deptId, String tableId, String nodeId, String loginUserId, String loginIp) throws Exception {
		List<Map<String, String>> resList = new ArrayList<Map<String, String>>();
		String path = JProperties.getFileProperties("archivefilepath");
		int length = new JSONTokener(attachments).length();

		try {
			if (length != 0) {
				Object datasJson = new JSONTokener(attachments).nextValue();
				if (datasJson instanceof JSONObject) {
					// 解析附件JSON串信息
					// 读取条目数据信息
					JSONObject j = JSONObject.fromObject(attachments);// 从JSON中读取附件信息
					String attachmentName = j.getString("attachmentId");// 附件名称(带后缀)
					String attachmentSaveName = j.getString("attachmentName"); // 保存数据库文件名(带后缀);
					String attachmentSecretLevel = j.getString("attachmentSecretLevel");// 附件密级
					String attachmentUploadType = j.getString("attachmentUploadType");// 附件类型 1 电子件 2扫描影像 3红头文件
					String attachmentDataId = j.getString("attachmentDataId");// 电子文件所属条目ID
					String useCount = j.getString("useCount");// 使用次数
					String attachSaveId = j.getString("attach_save_id");// 附件id
					// 2018.03.12新增附件md5验证
					String attachmentMD5 = j.getString("attachmentMD5");
					// 转换附件密级code
					String slCode = attachmentSecretLevel;
					Collection<SysLookupSimpleVo> ssv = upLoader.getLookUpListByType("CBB_SECRET");
					for (SysLookupSimpleVo sysLookupSimpleVo : ssv) {
						if (attachmentSecretLevel.equals(sysLookupSimpleVo.getLookupName())) {
							slCode = sysLookupSimpleVo.getLookupCode();
							break;
						}
					}
					// 从临时文件夹读取附件信息
					String folderPath = path + File.separator + attachmentDataId;// 文件夹路径
					String filePath = folderPath + File.separator + attachmentName;// 文件路径
					File file = new File(filePath);
					// 记录日志
					Map<String, String> qwm = new HashMap<String, String>();// 全文日志集合
					qwm.put("docName", attachmentName);
					qwm.put("saveType", "");
					qwm.put("tableName", tableName);
					qwm.put("nodeId", nodeId);
					qwm.put("gdResult", "成功");
					qwm.put("flag", "0");
					qwm.put("dataSrc", "OADATA");
					qwm.put("id", dataId);
					if (file.exists()) {
						// 验证附件md5
						String md5Key = this.getMD5(file);
						if (!attachmentMD5.equals(md5Key)) {
							qwm.put("gdResult", "失败： 条目id为： " + dataId + "的附件[" + attachmentName + "]，附件MD5验证不通过！");
							qwm.put("flag", "1");
							resList.add(qwm);
							throw new Exception();
						}
						List<File> filelist = new ArrayList<File>();
						filelist.add(file);
						Map<String, Object> param = new HashMap<String, Object>();
						param.put("businessId", dataId);
						param.put("businessTableName", tableName);
						param.put("attachmentSaveName", attachmentSaveName);
						param.put("category", "");
						param.put("secretLevel", slCode);
						param.put("mongoId", sysId);
						param.put("uploadType", attachmentUploadType);
						param.put("tableId", tableId);
						param.put("userId", loginUserId);
						param.put("loginIp", loginIp);
						param.put("nodeId", nodeId);
						param.put("useCount", useCount);
						param.put("attachSaveId", attachSaveId);
						// 调用附件上传公共方法
						fileUploadIntfsService.saveAttachmentBySaveTypeByIntfs(orgId, deptId, sysId, filelist, param);
						resList.add(qwm);
						// 删除该文件
						file.delete();
						// 如果该文件夹已空,那么删除该文件夹
						File d = new File(folderPath);// 文件夹对象
						File list[] = d.listFiles();
						if (list.length == 0) {
							d.delete();// 删除该文件夹
						}
					} else {
						// 记录不存在电子文件的日志，并且返回
						qwm.put("gdResult", "失败： 条目id为： " + dataId + "的附件[" + attachmentName + "]，无法在服务器中读取该文件，文件未上传到服务器中！");
						qwm.put("flag", "1");
						resList.add(qwm);
						throw new Exception();
					}
				} else if (datasJson instanceof JSONArray) {
					List<Map<String, Object>> attachList = new ArrayList<Map<String, Object>>();
					// 是否有文件不存在
					boolean isHave = true;
					// 文件MD5是否正确
					boolean md5True = true;
					// 解析附件JSON串信息
					JSONArray ja = JSONArray.fromObject(attachments);
					for (int i = 0; i < ja.size(); i++) {
						Map<String, Object> attachMap = new HashMap<String, Object>();
						// 读取条目数据信息
						JSONObject j = JSONObject.fromObject(ja.get(i));// 从JSON中读取附件信息
						String attachmentName = j.getString("attachmentId");// 附件名称(带后缀)
						String attachmentSaveName = j.getString("attachmentName"); // 保存数据库文件名(带后缀);
						String attachmentSecretLevel = j.getString("attachmentSecretLevel");// 附件密级
						String attachmentUploadType = j.getString("attachmentUploadType");// 附件类型 1 电子件 2扫描影像 3红头文件
						//String attachmentDataId = j.getString("attachmentDataId");// 电子文件所属条目ID
						String useCount = j.getString("useCount");// 使用次数
						String attachSaveId = j.getString("attach_save_id");// 附件id
						// 2018.03.12新增附件md5验证
						String attachmentMD5 = j.getString("attachmentMD5");
						// 转换附件密级code
						String slCode = attachmentSecretLevel;
						Collection<SysLookupSimpleVo> ssv = upLoader.getLookUpListByType("CBB_SECRET");
						for (SysLookupSimpleVo sysLookupSimpleVo : ssv) {
							if (attachmentSecretLevel.equals(sysLookupSimpleVo.getLookupName())) {
								slCode = sysLookupSimpleVo.getLookupCode();
								break;
							}
						}
						// 从临时文件夹读取附件信息
						String folderPath = path;// 文件夹路径
						String filePath = folderPath + File.separator + attachmentName;// 文件路径
						File file = new File(filePath);
						attachMap.put("folderPath", folderPath);
						attachMap.put("attachmentName", attachmentName);
						if (file.exists()) {
							// 验证附件md5
							String md5Key = this.getMD5(file);
							if (!attachmentMD5.equals(md5Key)) {
								md5True = false;
								break;
							}
							List<File> filelist = new ArrayList<File>();
							filelist.add(file);
							Map<String, Object> param = new HashMap<String, Object>();
							param.put("businessId", dataId);
							param.put("businessTableName", tableName);
							param.put("attachmentSaveName", attachmentSaveName);
							param.put("category", "");
							param.put("secretLevel", slCode);
							param.put("mongoId", sysId);
							param.put("uploadType", attachmentUploadType);
							param.put("tableId", tableId);
							param.put("userId", loginUserId);
							param.put("loginIp", loginIp);
							param.put("nodeId", nodeId);
							param.put("useCount", useCount);
							param.put("attachSaveId", attachSaveId);
							// 唯一验证
							param.put("unique_id", attachmentName);
							attachMap.put("attach", filelist);
							attachMap.put("param", param);
							attachList.add(attachMap);
						} else {
							attachList.add(attachMap);
							isHave = false;
							break;
						}
					}
					for (int i = 0; i < attachList.size(); i++) {
						Map<String, Object> m = attachList.get(i);
						//String folderPath = (String) m.get("folderPath");
						String attachmentName = (String) m.get("attachmentName");
						List<File> filelist = (List<File>) m.get("attach");
						Map<String, Object> param = (Map<String, Object>) m.get("param");
						// 记录日志
						Map<String, String> qwm = new HashMap<String, String>();// 全文日志集合
						qwm.put("docName", attachmentName);
						qwm.put("saveType", "");
						qwm.put("tableName", tableName);
						qwm.put("nodeId", nodeId);
						qwm.put("dataSrc", "OADATA");
						qwm.put("id", dataId);
						if (md5True == false) {
							// 记录md5验证不通过的电子文件的日志，并且返回
							qwm.put("flag", "1");
							qwm.put("gdResult", "失败： 条目id为： " + dataId + "的附件[" + attachmentName + "]，附件MD5验证不通过！");
							resList.add(qwm);
							throw new Exception();
						}
						if (isHave == true) {
							// 调用附件上传公共方法
							fileUploadIntfsService.saveAttachmentBySaveTypeByIntfs(orgId, deptId, sysId, filelist, param);
							qwm.put("flag", "0");
							qwm.put("gdResult", "成功：条目id为：" + dataId + "的附件[" + attachmentName + "]，上传成功！");
							resList.add(qwm);
						} else {
							// 记录不存在电子文件的日志，并且返回
							qwm.put("flag", "1");
							qwm.put("gdResult", "失败： 条目id为： " + dataId + "的附件[" + attachmentName + "]，无法在服务器中读取该文件，文件未上传到服务器中！");
							resList.add(qwm);
							throw new Exception();
						}
						// if (null != filelist) {
						// for (int j = 0; j < filelist.size(); j++) {
						// File file = filelist.get(j);
						// // 删除该文件
						// file.delete();
						// // 如果该文件夹已空,那么删除该文件夹
						// File d = new File(folderPath);// 文件夹对象
						// File list[] = d.listFiles();
						// if (list.length == 0) {
						// d.delete();// 删除该文件夹
						// }
						// }
						// }
					}
				}
			}
		} catch (Exception e) {
			return resList;
		}
		return resList;
	}

	/***
	 * 获取组合项配置信息Map（用于应用页面判断取值）
	 *
	 * @author 郭亮
	 * @param sourceId
	 * @param tableId
	 * @param recordId
	 * @return
	 * @throws Exception
	 *             Map<String,Map<String,Map<String,String>>>
	 * @throws
	 */
	public Map<String, Map<String, Map<String, String>>> getConfigMap(String sourceId, String tableId, String recordId) throws Exception {
		Map<String, Map<String, Map<String, String>>> map = new HashMap<String, Map<String, Map<String, String>>>();
		// 根据源字段Id查找配置信息
		if (!"".equals(sourceId)) {
			CbbTables cbbTables = this.getCbbTablesById(sourceId);//表ID
			String sourceName = cbbTables.getTableName();//表名称
			
			
			
			StringBuffer sbSql = new StringBuffer();
			sbSql.append("SELECT T.GROUP_ORDER, T.TARGET_TABLE_ID, T.TARGET_COLUMN_ID, T.TARGET_INPUT\n");
			sbSql.append("  FROM CBB_TAB_COL_CONFIG_GROUP T\n");
			sbSql.append(" WHERE T.SOURCE_COLUMN_ID = '" + sourceId + "'");
			List<Object[]> list = this.hibernateDao.findBySQL(sbSql.toString());
			if (list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					Map<String, Map<String, String>> orderMap = new HashMap<String, Map<String, String>>();
					Map<String, String> flagMap = new HashMap<String, String>();
					String order = (String) list.get(i)[0];
					String tgtTableId = (String) list.get(i)[1];
					String tgtColumnId = (String) list.get(i)[2];
					String tgtInput = (String) list.get(i)[3];
					String flag = ""; // 是否本表字段标示，Y：是；N：否
					String tgtColumnName = ""; // 组合字段名（当组合字段为本表字段时，tgtColumnName为字段名；当为外表字段时，tgtColumnName为某条数据的具体值）
					String colName = "";// 列英文名
					String colType = "";// 列类型
					List<Map<String, Object>> listCol = commTableManagerIntfsService.getCbbColumnsByColIdByIntfs(tgtColumnId);
					if (listCol.size() > 0) {
						colName = String.valueOf(listCol.get(0).get("COL_NAME"));
						colType = String.valueOf(listCol.get(0).get("COL_TYPE"));
					}
					String tableName = "";
					List<Map<String, Object>> tabList = commTableManagerIntfsService.getCbbTableAndColumnsByTabIdByIntfs(tgtTableId);
					if (tabList.size() > 0) {
						tableName = String.valueOf(tabList.get(0).get("TABLE_NAME"));
					}
					if (!"".equals(colName) && !"".equals(tableName)) {
						if (tableId.equals(tgtTableId)) { // 本表字段
							flag = "Y";
							// 通过tgtColumnId查找ColumnName
							tgtColumnName = colName;
						} else { // 非本表字段
							flag = "N";
							/*** 获取外表数据字段对应值 ***/
							// 根据表名，列名，数据行Id获取数据
							String dataSql = "SELECT T." + colName + " FROM " + tableName + " T WHERE T.ID = '" + recordId + "'";
							List<Object> dataList = this.hibernateDao.findBySQL(dataSql);
							if (dataList.size() > 0) {
								if ("integer".equals(colType) || "float".equals(colType)) {
									tgtColumnName = (String.valueOf(dataList.get(0))).equals("null") ? "" : String.valueOf(dataList.get(0));
								} else {
									tgtColumnName = dataList.get(0) == null ? "" : (String) dataList.get(0);
								}
							}
						}
						flagMap.put(flag, tgtInput == null ? "" : tgtInput);
						orderMap.put(tgtColumnName, flagMap);
						map.put(order, orderMap);
					}
				}
			}
		}
		return map;
	}

	/***
	 * 根据源字段ID获取该字段的组合项配置信息
	 *
	 * @author 郭亮
	 * @param sourceId
	 * @param tableId
	 * @param recordId
	 * @return 配置信息字符串的形式为:order（顺序）,tgtColName（组合字段名）,flag（本表标识）,tgtInput（固定值）,
	 *         colDropdownType（组合字段下拉类型）,colIsComplement(是否补足),colComplementNum(补足位数);order, tgtColName,flag,
	 *         tgtInput,colDropdownType,colIsComplement,colComplementNum
	 *         flag为Y时tgtColName为组合字段字段名，为N时tgtColName为具体值
	 * @throws Exception
	 */
	@Override
	public String getConfigStr(String sourceId, String tableId, String recordId) throws Exception {
		// 根据源字段Id查找配置信息
		String str = "";
		if (!"".equals(sourceId)) {
			//根据表ID获得表信息
			CbbTables cbbTable = this.getCbbTablesById(tableId);
			//获得表名称
			String tableName = cbbTable.getTableName();
			
			//根据字段Id获得字段信息
			CbbTabColumns cbbTabColumns = this.getCbbTabColumnsById(sourceId);
			//获得组合项配置信息
			String colGeneMethodRule = cbbTabColumns.getColGeneMethodRule();
			if(null == colGeneMethodRule || "".equals(colGeneMethodRule)){
				return str;
			}
			if(null == recordId || "".equals(recordId)){
				return "";
			}
			
			//根据数据ID获得表数据信息
			String sbSql = "SELECT　* FROM "+tableName+" WHERE ID = '"+recordId+"'";
			List<Map<String,Object>> list = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql);
			if(list.size()>0){
				Map<String,Object> map = list.get(0);
				//得到map的key
				for(Entry<String, Object> entry:map.entrySet()){
					String key = entry.getKey();
					Object colValue = entry.getValue();
					String colName = tableName.toUpperCase()+"."+key.toUpperCase();
					if(colValue!=null&&colName!=null){
						if((key.toUpperCase().equals("QRQ")||key.toUpperCase().equals("ZRQ"))&&colValue.toString().indexOf("-")!=-1){ // 只判断起止日期 SanXiaFiles create by zhaoxiaolong
							colValue = colValue.toString().replaceAll("-","@***&&&**(");
						}
						if (key.toUpperCase().equals("BGH")){
							String bghValue = String.valueOf(colValue);
							int count = Integer.valueOf(bghValue);
							bghValue = String.valueOf(count);
							colValue = this.getBghStr(bghValue);
						}
					}
					if(colGeneMethodRule.indexOf(colName)>-1){
//						LANTOP_WS_20_WJ.ARCHIVE_MANA_PERIOD
						if(null != colValue){
							if (colName.indexOf("ARCHIVE_MANA_PERIOD")>-1){
								if ("永久".equals(colValue)){
									colValue = "Y";
								}
							}
							colGeneMethodRule = colGeneMethodRule.replaceAll(colName, "'"+colValue.toString()+"'");
						}
					}
		        }
				
				Object obj = DynamicExeMain.eval(colGeneMethodRule);
				if(null != obj){
					str = obj.toString();
				}
			}
		}
		return str;

			/*StringBuffer sbSql = new StringBuffer();
			sbSql.append("SELECT T.GROUP_ORDER, T.TARGET_TABLE_ID, T.TARGET_COLUMN_ID, T.TARGET_INPUT\n");
			sbSql.append("  FROM CBB_TAB_COL_CONFIG_GROUP T\n");
			sbSql.append(" WHERE T.SOURCE_COLUMN_ID = '" + sourceId + "' ORDER BY T.GROUP_ORDER");
			List<Object[]> list = this.hibernateDao.findBySQL(sbSql.toString());
			if (list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					// Map<String, Map<String, String>> orderMap = new
					// HashMap<String, Map<String, String>>();
					// Map<String, String> flagMap = new HashMap<String,
					// String>();
					String order = (String) list.get(i)[0];
					String tgtTableId = (String) list.get(i)[1];
					String tgtColumnId = (String) list.get(i)[2];
					String tgtInput = String.valueOf(list.get(i)[3]);
					if ("null".equals(tgtInput)) {
						tgtInput = "";
					}
					String flag = ""; // 是否本表字段标示，Y：是；N：否
					String tgtColumnName = ""; // 组合字段名（当组合字段为本表字段时，tgtColumnName为字段名；当为外表字段时，tgtColumnName为某条数据的具体值）
					String colName = "";// 列英文名
					String colType = "";// 列类型
					String colDropdownType = "";// 列下拉类型
					String colIsComplement = "";// 是否补足
					String colComplementNum = "";// 补足位数
					List<Map<String, Object>> listCol = commTableManagerIntfsService.getCbbColumnsByColIdByIntfs(tgtColumnId);
					if (listCol.size() > 0) {
						colName = String.valueOf(listCol.get(0).get("COL_NAME"));
						colType = String.valueOf(listCol.get(0).get("COL_TYPE"));
						colDropdownType = String.valueOf(listCol.get(0).get("COL_DROPDOWN_TYPE"));
						colIsComplement = String.valueOf(listCol.get(0).get("COL_IS_COMPLEMENT"));
						colComplementNum = String.valueOf(listCol.get(0).get("COL_COMPLEMENT_NUM"));
					}
					String tableName = "";
					List<Map<String, Object>> tabList = commTableManagerIntfsService.getCbbTableAndColumnsByTabIdByIntfs(tgtTableId);
					if (tabList.size() > 0) {
						tableName = String.valueOf(tabList.get(0).get("TABLE_NAME"));
					}
					if (tableId.equals(tgtTableId)) { // 本表字段
						flag = "Y";
						// 通过tgtColumnId查找ColumnName
						tgtColumnName = colName;
					} else { // 非本表字段
						flag = "N";
						*//*** 获取外表数据字段对应值 ***//*
						// 根据表名，列名，数据行Id获取数据
						if (null != recordId && !"".equals(recordId)) {
							if (null == colName || colName.equals("")) {
								tgtColumnName = "";
							} else {
								String dataSql = "SELECT T." + colName + " FROM " + tableName + " T WHERE T.ID = '" + recordId + "'";
								List<Object> dataList = this.hibernateDao.findBySQL(dataSql);
								if (dataList.size() > 0) {
									if ("integer".equals(colType) || "float".equals(colType)) {
										tgtColumnName = (String.valueOf(dataList.get(0))).equals("null") ? "" : String.valueOf(dataList.get(0));
									} else {
										tgtColumnName = dataList.get(0) == null ? "" : (String) dataList.get(0);
									}
								}
							}
						}

					}
					str = str + ";" + order + "," + tgtColumnName + "," + flag + "," + tgtInput + "," + colDropdownType + "," + colIsComplement + "," + colComplementNum;
				}
			}
		}
		if (!"".equals(str)) {
			str = str.substring(1);
		}
		return str;*/
	}

	public S3Service getS3Service() {
		return S3Service.getInstance();
	}

	public AmazonS3 getS3() throws Exception {
		return getS3Service().getS3Instance();
	}

	/**
	 * 根据数据id删除附件数据和mongdb数据
	 *
	 * @author 钟一华
	 * @param dataId
	 * @throws Exception
	 *             void
	 * @throws
	 */
	@Override
	public void deleteAttachmentByDataIdsByIntfs(List<String> dataIds, String sysId) throws Exception {
		String bucketName = JProperties.getFileProperties("bucketName"); // 桶名
		String folderName = JProperties.getFileProperties("folderName");
		String sqlIds = "";
		for (int i = 0; i < dataIds.size(); i++) {
			sqlIds = sqlIds + "'" + dataIds.get(i) + "',";
		}
		sqlIds = sqlIds + "''";
		String sql = "delete from cbb_doc_relation where record_id in(" + sqlIds +")";
		this.jdbcAvicit.getJdbcTemplate().execute(sql);
	}

	/**
	 * 根据配置规则，给表中数据重新插入数据
	 *
	 * @author 朱锋
	 * @param sysId
	 * @param conditionMap
	 *            void
	 * @throws
	 */
	@Override
	public void insertFieldValueByConditionMapByIntfs(String sysId, String orgId, String deptId, Map<String, Object> conditionMap) throws Exception {
	}

	/**
	 * 生成全部档号或所选档号
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param paramMap
	 *            参数MAP [p1：key='flag'，value：boolean 必填（是否全部记录，true全部，false部分）]
	 *            [p2：key='recordId'，value：list<String> 非必填（部分记录ID）]
	 *            [p3：key='tableId'，value：String 必填（表ID）]
	 *            [p4：key='parentId'，value：String 非必填（案卷级数据ID）]
	 * @throws Exception
	 *             void
	 * @throws
	 */
	@Override
	public void updateRecordByArchiveCodeByIntfs(String orgId, String deptId, String sysId, Map<String, Object> paramMap) throws Exception {
		String modleName = "XXX模块";
		// 根据组合项配置信息拼接sql
		String colNameStr = "''";// sql字段
		if (paramMap.containsKey("modleName")) {
			modleName = (String) paramMap.get("modleName");
		}
		String nodeId = paramMap.get("nodeId")==null?"":paramMap.get("nodeId").toString();
		if (paramMap.containsKey("flag")) {
			String archiveCode = String.valueOf(paramMap.get("archiveCode"));// 案卷级档号
			String archiveInNum = String.valueOf(paramMap.get("archiveInNum"));// 卷内顺序号
			if (paramMap.containsKey("tableId")) {
				String tableId = String.valueOf(paramMap.get("tableId"));// 表ID
				boolean flag = (Boolean) paramMap.get("flag");// 是否全部记录，true全部，false部分
				if (!StringUtils.isEmpty(archiveCode)) {
					colNameStr = archiveCode +"-"+ archiveInNum;
					List<Map<String, Object>> tabList = commTableManagerIntfsService.getCbbTableAndColumnsByTabIdByIntfs(tableId);
					String tableName = "";// 表名
					if (tabList.size() > 0) {
						tableName = String.valueOf(tabList.get(0).get("TABLE_NAME"));
					}
					if ("".equals(tableName)) {
						throw new Exception("调用接口时，“tableId”参数值无效，请检查！");
					}
					StringBuffer sbSql = new StringBuffer();
					sbSql.append("UPDATE " + tableName + " T\n");
					sbSql.append("   SET T.ARCHIVE_CODE =('");
					sbSql.append(colNameStr);
					sbSql.append("' ) ");
					if (!flag) {
						// 部分
						if (paramMap.containsKey("recordId")) {
							List<String> recordList = (List<String>) paramMap.get("recordId");
							if (recordList.size() > 0) {
								sbSql.append(" WHERE T.ID IN (");
								for (int i = 0; i < recordList.size(); i++) {
									if (i == 0) {
										sbSql.append("'" + recordList.get(i) + "'");
									} else {
										sbSql.append(",'" + recordList.get(i) + "'");
									}
								}
								sbSql.append(")");
							}
						} else {
							throw new Exception("调用接口时，“tableId”参数不存在，请检查！");
						}
					} else {
						// 全部
						if (paramMap.containsKey("parentId")) {
							String parentId = String.valueOf(paramMap.get("parentId"));// 案卷级数据ID
							if (null != parentId && !"".equals(parentId) && !"null".equals(parentId)) {
								sbSql.append(" WHERE T.PARENT_ID = '" + parentId + "'");
								if (paramMap.containsKey("searchCondition")) {
									sbSql.append(paramMap.get("searchCondition"));
								}
							} else {
								if (paramMap.containsKey("searchCondition")) {
									sbSql.append("WHERE 1 = 1 " + paramMap.get("searchCondition"));
								}
							}
						}
					}
					// 执行JDBC更新方法
					executeJdbc(sysId, sbSql.toString(), "update", orgId, deptId, modleName);
				} else {
					List<Map<String, Object>> colList = commTableManagerIntfsService.getCbbColumnsByTableIdAndColNameByIntfs(tableId, "ARCHIVE_CODE");
					if (colList.size() > 0) {
						List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
						List<Map<String, Object>> tabList = commTableManagerIntfsService.getCbbTableAndColumnsByTabIdByIntfs(tableId);
						String tableName = "";// 表名
						if (tabList.size() > 0) {
							tableName = String.valueOf(tabList.get(0).get("TABLE_NAME"));
							List<String> recordList = (List<String>) paramMap.get("recordId");
							/** 2019/09/30 SanXiaFiles create by zhaoxiaolong 检测档号是否重复 重复则重新生成保管号 **/
							StringBuffer suSql = new StringBuffer();
							String currentClassNo = ""; // 当前类别号
							/** 2019/11/21 SanXiaFiles create by zhaoxiaolong 验证类别号是否正确 **/
							StringBuffer sbSql = new StringBuffer();
							String remark = ""; // 节点名称备注
							String classNo = ""; // 类别号
							if(paramMap.size()>0&&paramMap.get("nodeId")!=null){
								sbSql.append(" SELECT REMARK FROM LANTOP_ARCHIVE_CLASS WHERE ID='"+paramMap.get("nodeId")+"'");
								List<Map<String,Object>> mapList = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
								if(mapList.size()>0){
									remark = mapList.get(0).get("REMARK").toString();
								}
								if(remark!=""&&!remark.equals("")){
									remark = remark.substring(0,remark.lastIndexOf(";"));
									remark = remark.replace("ARCHIVE_CLASSNO=","");
									classNo = remark;
								}
							}
							if(recordList.size()>0){
								for (int i = 0; i < recordList.size(); i++) {
									// 遍历传过来的集合，查询对应档号是否存在
									String archiveCodeVal = "";
									String bgh = "";
									StringBuffer acSql = new StringBuffer();
									sbSql = new StringBuffer();
									acSql.append("SELECT ARCHIVE_CODE,BGH,ARCHIVE_CLASSNO FROM "+tableName+" WHERE ID = '"+recordList.get(i)+"'");
									List<Map<String,Object>> codeList = this.jdbcAvicit.getJdbcTemplate().queryForList(acSql.toString());
									if(codeList.size()>0){
										archiveCodeVal = codeList.get(0).get("ARCHIVE_CODE")==null?"":codeList.get(0).get("ARCHIVE_CODE").toString(); // 当前档号
										bgh = codeList.get(0).get("BGH")==null?"":codeList.get(0).get("BGH").toString(); // 当前保管号
										currentClassNo = codeList.get(0).get("ARCHIVE_CLASSNO")==null?"":codeList.get(0).get("ARCHIVE_CLASSNO").toString(); // 当前类别号
									}
									int count = 0;
//									if(archiveCodeVal!=""){
									if(!"".equals(archiveCodeVal)){
										sbSql.append("SELECT COUNT(1) COUNT FROM "+tableName+" WHERE ARCHIVE_CODE = '"+archiveCodeVal+"'"); // 判断档号是否有重复，记录最大的条数
										List<Map<String,Object>> list = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
										if(list.size()>0){
											count = Integer.valueOf(list.get(0).get("COUNT").toString());
										}
									}
									if(!currentClassNo.equals(classNo)){ // 类别号不一致时，更新类别号
										StringBuffer upSql = new StringBuffer();
										upSql.append("UPDATE "+tableName+" SET ARCHIVE_CLASSNO='"+classNo+"' WHERE ID='"+recordList.get(i)+"'");
										this.jdbcAvicit.getJdbcTemplate().execute(upSql.toString());
										count = 2;
									}
									if(count>1||"".equals(bgh)){  //生成条件 : 根据当前档号查询到条数大于1 或者 保管号为空
										suSql.append(recordList.get(i) + ","); // 拼接重复档号的ID,待进行重新生成保管号
									}
//									suSql.append(recordList.get(i) + ",");
								}
							}

							/** 自动保管号生成 SanxiaFiles create by zhaoxiaolong start **/
							/*StringBuffer suSql = new StringBuffer();
							suSql.append("SELECT ID FROM "+tableName+" WHERE BGH IS NULL");
							if (paramMap.containsKey("recordId")) {
								// List<String> recordList = (List<String>) paramMap.get("recordId");
								if (recordList.size() > 0) {
									suSql.append(" AND ID IN (");
									for (int i = 0; i < recordList.size(); i++) {
										if (i == 0) {
											suSql.append("'" + recordList.get(i) + "'");
										} else {
											suSql.append(",'" + recordList.get(i) + "'");
										}
									}
									suSql.append(") ORDER BY CREATION_DATE DESC");
								}
							}
							// 获取勾选数据中档案保管号为空的数据
							List<Map<String,Object>> listData = this.jdbcAvicit.getJdbcTemplate().queryForList(suSql.toString());
							StringBuffer bgSql = new StringBuffer();
							for (int i = 0; i < listData.size(); i++) {
								if (i == 0) {
									bgSql.append("" + listData.get(i).get("ID") + "");
								} else {
									bgSql.append("," + listData.get(i).get("ID") + "");
								}
							}*/
							if(suSql.toString().length()>0){
								Map<String, Object> params = new HashMap<>();
								String ids = suSql.toString().substring(0,suSql.lastIndexOf(","));
								params.put("recordIds", ids);  // 待生成保管号的ID字符串
								params.put("tableId",tableId);  // 表ID
								params.put("nodeId",nodeId);  // 数据节点id
								boolean flags = this.updateBghByRecordIdByIntfs(orgId, deptId, sysId, params); // 生成所选保管号
								if(flags=false){
									throw new Exception("生成所选保管号失败！");
								}
								/** SanxiaFiles create by zhaoxiaolong end **/
							}
						}
						if ("".equals(tableName)) {
							throw new Exception("调用接口时，“tableId”参数值无效，请检查！");
						}
						
						String colId = String.valueOf(colList.get(0).get("ID"));// 档号列ID
						if (!flag) {
							// 部分
							if (paramMap.containsKey("recordId")) {
								List<String> recordList = (List<String>) paramMap.get("recordId");
								for(String str:recordList){
									String groupConfigStr = getConfigStr(colId, tableId, str);
									if(!"".equals(groupConfigStr)){
										Map<String,Object> map = new HashMap<String,Object>();
										map.put("ARCHIVE_CODE", groupConfigStr);
										map.put("ID", str);
										listMap.add(map);
									}
								}
							}
						}else{
							//全部
							if (paramMap.containsKey("parentId")) {
								String parentId = String.valueOf(paramMap.get("parentId"));// 案卷级数据ID
								String sql = "";
								if (null != parentId && !"".equals(parentId) && !"null".equals(parentId)) {
									sql =  " SELECT　T.ID FROM "+tableName+" T WHERE T.PARENT_ID = '"+parentId+"'";
								}else{
									if (paramMap.containsKey("searchCondition")) {
										sql = " SELECT　T.ID FROM "+tableName+" T WHERE 1 = 1 " + paramMap.get("searchCondition");
									}
								}
								if(sql.equals("")){
									sql = " SELECT T.ID FROM "+ tableName + " T";
								}
								List<String> list = this.jdbcAvicit.getJdbcTemplate().queryForList(sql, String.class);
								for(String str:list){
									String groupConfigStr = getConfigStr(colId, tableId, str);
									if(groupConfigStr.equals("")){
									    // 生成档号失败
									    throw new Exception("生成档号失败");
                                    }
									if(!"".equals(groupConfigStr)){
										Map<String,Object> map = new HashMap<String,Object>();
										map.put("ARCHIVE_CODE", groupConfigStr);
										map.put("ID", str);
										listMap.add(map);
									}
								}
							}
						}


						// 连接池
						DBConnectionCustomManager connectionMan = null;
						String poolName = orgId + "_" + sysId;
						Connection conn = null;
						PreparedStatement ps = null;
						try {
							// 实例化连接池
							connectionMan = DBConnectionCustomManager.getInstance(poolName);
							// 获取连接
							conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
							conn.setAutoCommit(false);
							StringBuffer deleteSql = new StringBuffer();
							deleteSql.append("UPDATE " + tableName + " SET ARCHIVE_CODE = ? WHERE ID = ?");
							ps = conn.prepareStatement(deleteSql.toString());
							// 批量更新
							for (Map<String,Object> m : listMap) {
								ps.setString(1, m.get("ARCHIVE_CODE").toString());
								ps.setString(2, m.get("ID").toString());
								ps.addBatch();
							}
							ps.executeBatch();
							conn.commit();
						} catch (Exception e) {
							conn.rollback();
							e.printStackTrace();
							throw new Exception("数据库操作异常，请联系管理员！");
						} finally {
							if (ps != null) {
								try {
									ps.close();
								} catch (Exception e) {
									e.printStackTrace();
								}
							}
							if (conn != null) {
								try {
									conn.setAutoCommit(true);
									connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
								} catch (Exception e) {
									e.printStackTrace();
								}
							}
						}
					}
				}
			} else {
				throw new Exception("调用接口时，“tableId”参数不存在，请检查！");
			}
		} else {
			throw new Exception("调用接口时，“flag”参数不存在，请检查！");
		}
	}

	/**
	 * 生成所选数据保管号
	 * 
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param paramMap
	 *            参数MAP
	 *            [p1：key='recordIds'，value：list<String> 必填（记录ID）]
	 *            [p2：key='tableId'，value：String 必填（表ID）]
	 * @throws Exception
	 *             void
	 * @throws
	 */
	@Override
	public boolean updateBghByRecordIdByIntfs(String orgId, String deptId, String sysId, Map<String, Object> paramMap) throws Exception {
		boolean flag = false;
		String recordIds = "";//所选记录集合
		if (paramMap.containsKey("recordIds")) {
			recordIds = (String) paramMap.get("recordIds");
		}
		String tableId = "";//表ID
		if (paramMap.containsKey("tableId")) {
			tableId = (String) paramMap.get("tableId");
		}
		String nodeId = paramMap.get("nodeId")==null?"":paramMap.get("nodeId").toString();
		try{
			if(!"".equals(tableId)){
				//查询表中保管号字段的
				List<Map<String, Object>> colList = commTableManagerIntfsService.getCbbColumnsByTableIdAndColNameByIntfs(tableId, "BGH");
				if (colList.size() > 0) {
					String colGeneMethod = String.valueOf(colList.get(0).get("COL_GENE_METHOD"));// 生成方式
					if("2".equals(colGeneMethod)){
						String colGeneMethodRule = String.valueOf(colList.get(0).get("COL_GENE_METHOD_RULE"));// 序列规则 1:YEAR;
						String[] r = colGeneMethodRule.split(":");//获取步长及组合字段
						if(r.length == 2){
							List<Map<String, Object>> tabList = commTableManagerIntfsService.getCbbTableAndColumnsByTabIdByIntfs(tableId);
							String tableName = "";// 表名
							if (tabList.size() > 0) {
								tableName = String.valueOf(tabList.get(0).get("TABLE_NAME"));
							}
							//根据组合字段拼写SQL查询具体的值
							String cs = "";//SQL查询字段
							String bc = r[0];//步长
							String col = r[1];//组合字段
							String[] cols = col.split(";");
							for (int i = 0; i < cols.length; i++) {
								cs += "T." + cols[i] + ",";
							}
							cs = cs.substring(0,cs.length()-1);
							String[] rIds = recordIds.split(",");
							for(int i = 0; i < rIds.length; i++) {
								StringBuffer sbSql = new StringBuffer();
								String rId = rIds[i];
								sbSql.append("SELECT " + cs + " FROM " + tableName + " T WHERE T.ID = '" + rId + "'");
								List<Map<String, Object>> vaList = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
								if(vaList.size() > 0){
									Map<String, Object> vamap = vaList.get(0);
									// 取该条数据下最大的保管号
									StringBuffer sbSql1 = new StringBuffer();//档案整理当前最大保管号
									StringBuffer sbSql2 = new StringBuffer();//档案保管当前最大保管号
									StringBuffer sbSql3 = new StringBuffer();//大于入库的 保管号数据
									sbSql1.append("SELECT CASE WHEN MAX(TO_NUMBER(S.BGH))  IS NULL THEN 0 ELSE  MAX(TO_NUMBER(S.BGH))  END BGH FROM "+tableName+" S WHERE 1=1 \n");
									sbSql1.append(" AND S.ARCHIVE_STATUS = '1'");
									sbSql2.append("SELECT CASE WHEN MAX(TO_NUMBER(S.BGH))  IS NULL THEN 0 ELSE  MAX(TO_NUMBER(S.BGH))  END BGH FROM "+tableName+" S WHERE 1=1 \n");
									sbSql2.append(" AND S.ARCHIVE_STATUS = '3'");
									sbSql3.append("SELECT TM,TO_NUMBER(BGH) AS BGH FROM "+tableName+" S WHERE 1=1 \n");
									sbSql3.append(" AND S.ARCHIVE_STATUS IN ('3','1')");
									if (nodeId!=null&&!"".equals(nodeId)){
										sbSql1.append(" AND S.NODE_ID='"+nodeId+"'");
										sbSql2.append(" AND S.NODE_ID='"+nodeId+"'");
										sbSql3.append(" AND S.NODE_ID='"+nodeId+"'");
									}
									Iterator it = vamap.keySet().iterator();
									while(it.hasNext()){
										String key = String.valueOf(it.next());
										String value = String.valueOf(vamap.get(key));
										// 过滤为‘null’字符串条件
										if(value.equals("null")){
											sbSql1.append("   AND S." + key + " IS NULL ");
											sbSql2.append("   AND S." + key + " IS NULL ");
											sbSql3.append("   AND S." + key + " IS NULL ");
										}else{
											sbSql1.append("   AND S." + key + " = '" + value + "'");
											sbSql2.append("   AND S." + key + " = '" + value + "'");
											sbSql3.append("   AND S." + key + " = '" + value + "'");
										}
									}
									sbSql1.append(" AND ID !='"+rId+"' ");  // 求最大保管号，排除当前已有保管号
									sbSql2.append(" AND ID !='"+rId+"' ");  //
									sbSql3.append(" AND ID !='"+rId+"' ");  //

									List<Map<String,Object>> mapList = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql1.toString());
									List<Map<String,Object>> mapList1 = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql2.toString());
									int maxBgh = Integer.parseInt(mapList.get(0).get("BGH")==null?"0":mapList.get(0).get("BGH").toString());
									int maxBgh1 = Integer.parseInt(mapList1.get(0).get("BGH")==null?"0":mapList1.get(0).get("BGH").toString());

									sbSql3.append(" AND TO_NUMBER(BGH) >= '"+maxBgh1+"' AND TO_NUMBER(BGH) <= '"+maxBgh+"' ORDER BY BGH");
									List<Map<String,Object>> mapList2 = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql3.toString());
									List<Integer> sd = new ArrayList<>();
									int y = 0;
									String bghStr ="";
									for(Map<String,Object> map:mapList2){
										int q1 = Integer.parseInt(map.get("BGH").toString());
										if(sd.size()>0){
											if(q1 == sd.get(y)){

											} else {
												int bghc = sd.get(y)+1;
												if(bghc != q1){
													bghStr = String.valueOf(sd.get(y));
													break;
												}
											}
											y = y+1;
										}
										sd.add(q1);
										if(y==mapList2.size()-1){
											bghStr = String.valueOf(sd.get(y));
										}
									}
									if("".equals(bghStr)){
										bghStr = maxBgh1+Integer.parseInt(bc)+"";
									} else {
										bghStr = String.valueOf(Integer.parseInt(bghStr)+Integer.parseInt(bc));
									}
									bghStr = this.getBghStr(bghStr); // 自动补全四位
									//更新该条数据下的最大保管号
									sbSql1 = new StringBuffer();
									sbSql1.append("UPDATE " + tableName + " T\n");
									sbSql1.append("   SET T.BGH =\n");
									sbSql1.append("('"+bghStr+"')  WHERE T.ID = '" + rId + "'");
									// JDBC实现更新
									this.jdbcAvicit.getJdbcTemplate().update(sbSql1.toString());
									// executeJdbc(sysId, sbSql.toString(), "update", orgId, deptId, "更新保管号");
									flag=true;
								}
							}
						}
					}
				}
			}
		}
		catch (Exception e){
			e.printStackTrace();
			flag=false;
		}
		return flag;
	}
	
	/**
	 * 添加业务数据（后台应用配置添加）
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param param
	 *            参数MAP[p1：key='tableId'，value：String必填（表ID）]
	 *            [p2：key='mapObj'，value：Map<String（字段名）, Object（值）> 必填（新增值）]
	 *            [p3：key='loginUserId'，value：String 必填（登陆用户ID）]
	 *            [p4：key='loginIp'，value：String 必填（登陆用户IP）]
	 *            [p5：key='dataId'，value：String 非必填（顺带，序列应用时所选记录的ID）]
	 *            [p6：key='ortherConfigDataId'，value：String 非必填（组合项应用时兄弟表记录的ID）]
	 *            [p6：key='wjIds'，value：String 非必填（文件数据ID，组卷新增案卷时有值）]
	 * @return
	 * @throws Exception
	 *             String
	 * @throws
	 */
	@Override
	public String insertRecordByConfigByIntfs(String orgId, String deptId, String sysId, Map<String, Object> param) throws Exception {
		// 接参数
		String modleName = "XXX模块";
		if (param.containsKey("modleName")) {
			modleName = (String) param.get("modleName");
		}
		String tableId = "";// 表ID
		Map<String, Object> mapObj = new HashMap<String, Object>();// 新增值
		String loginUserId = "";// 登陆用户ID
		String loginIp = "";// 登陆用户IP
		String dataId = "";// 顺带，序列应用时所选记录的ID
		String ortherConfigDataId = "";// 组合项应用时兄弟表记录的ID
		// SanXiaFilesCreate by zhaoxiaolong 增加组合项ID
		String combinatorialTermId = "";
		if (param.containsKey("tableId")) {
			tableId = String.valueOf(param.get("tableId"));
		} else {
			throw new Exception("调用接口时，“tableId”参数不存在，请检查！");
		}
		if (param.containsKey("mapObj")) {
			mapObj = (Map<String, Object>) param.get("mapObj");
		} else {
			throw new Exception("调用接口时，“mapObj”参数不存在，请检查！");
		}
		if (param.containsKey("loginUserId")) {
			loginUserId = String.valueOf(param.get("loginUserId"));
		} else {
			throw new Exception("调用接口时，“loginUserId”参数不存在，请检查！");
		}
		if (param.containsKey("loginIp")) {
			loginIp = String.valueOf(param.get("loginIp"));
		} else {
			throw new Exception("调用接口时，“loginIp”参数不存在，请检查！");
		}
		if (param.containsKey("dataId")) {
			dataId = String.valueOf(param.get("dataId"));
		}
		if (param.containsKey("ortherConfigDataId")) {
			ortherConfigDataId = String.valueOf(param.get("ortherConfigDataId"));
		}
		// 开始方法主体
		Map<String, Object> allMap = new HashMap<String, Object>();
		List<Map<String, Object>> listCname = commTableManagerIntfsService.getCbbTabColumnsByIsAllByIntfs(orgId, deptId, sysId, tableId, "Y");// 所有字段名称集合
		CbbTables cbbTables = getCbbTablesById(tableId);// 根据tableId获取基本表对象
		List<Map<String, Object>> listDatas = new ArrayList<Map<String, Object>>();
		SysDept currentDept = deptLoader.getSysDeptBySysDeptId(deptId); // 上级部门代码
		SysDept paretnDept = deptLoader.getParentSysDeptBySysDeptId(deptId); // 上级部门代码
		String parentDeptId = "";
		String parentDeptCode = "";
		if (null != paretnDept) {
			parentDeptId = this.deptLoader.getParentSysDeptIdBySysDeptId(deptId); // 当前部门上级部门ID
			parentDeptCode = paretnDept.getDeptCode();
		} else {
			// 如果没有上级部门，那么取当前部门
			parentDeptId = deptId;
			parentDeptCode = currentDept.getDeptCode();
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		// 根据选中数据ID获取数据对象
		String dataSql = "SELECT T.* FROM " + cbbTables.getTableName() + " T WHERE T.ID = '" + dataId + "'";
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接

			statement = conn.createStatement();
			rs = statement.executeQuery(dataSql.toString());
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				// 循环字段集合添加数据
				for (int j = 0; j < listCname.size(); j++) {
					Map<String, Object> colMapj = listCname.get(j);
					String cName = String.valueOf(colMapj.get("COL_NAME"));
					map.put(cName, rs.getObject(cName));
				}
				listDatas.add(map);
			}
			for (int i = 0; i < listCname.size(); i++) {
				String value = "";
				Map<String, Object> colMap = listCname.get(i);
				String colName = String.valueOf(colMap.get("COL_NAME"));// 字段名
				String colIsDisplay = String.valueOf(colMap.get("COL_IS_DISPLAY"));// 是否可见
				String colIsVisible = String.valueOf(colMap.get("COL_IS_VISIBLE"));// 是否显示（添加/编辑）
				String colIsEdit = String.valueOf(colMap.get("COL_IS_EDIT"));// 是否可编辑（添加/编辑）
				String path = String.valueOf(colMap.get("CUSTOM_PATH"));// 自定义页面路径
				String colType = String.valueOf(colMap.get("COL_TYPE"));// 字段类型
				String colId = String.valueOf(colMap.get("ID"));// 字段ID
				if(colName.equals("ARCHIVE_CODE")){ // 将当前档号ID赋值于组合项ID
					combinatorialTermId = colId;
				}
				String nodeId = "";//数据节点ID
				if (mapObj.containsKey("NODE_ID") && null != mapObj.get("NODE_ID") && !"".equals(mapObj.get("NODE_ID"))) {
					nodeId = String.valueOf(mapObj.get("NODE_ID"));
				}
				if ("Y".equals(colIsDisplay) && "Y".equals(colIsVisible) && "Y".equals(colIsEdit)) {
					if (mapObj.containsKey(colName)) {
						value = String.valueOf(mapObj.get(colName));
						/*************** 序列规则 ***********/
						if ("2".equals(String.valueOf(colMap.get("COL_GENE_METHOD"))) && ("".equals(value) || "null".equals(value))) {
							// 判断是否有父数据
							if (mapObj.containsKey("PARENT_ID") && null != mapObj.get("PARENT_ID") && !"".equals(mapObj.get("PARENT_ID")) && "ARCHIVE_IN_NUM".equals(colName)) {
								String parentId = String.valueOf(mapObj.get("PARENT_ID"));
								String sql = " AND PARENT_ID = '" + parentId + "'";
								String num = "";
								Object obj = this.getOperationTableColDataByIntfs(tableId, sql, "ARCHIVE_IN_NUM", orgId, deptId, sysId, "MAX");
								if (null != obj) {
									num = obj.toString();
									int newNum = Integer.valueOf(num) + 1;
									num = newNum + "";
								} else {
									num = "1";
								}
								value = num;
							} else {
								String sql = "";
								if (!"".equals(nodeId)) {
									sql += " AND NODE_ID = '" + nodeId + "'";
								}
								String num = "";
								Object obj = this.getOperationTableColDataByIntfs(tableId, sql, colName, orgId, deptId, sysId, "MAX");
								if (null != obj) {
									num = obj.toString();
									int newNum = Integer.valueOf(num) + 1;
									num = newNum + "";
								} else {
									num = "1";
								}
								value = num;
							}
						}
						/*************** 组合项规则修改（配置组合项字段页面著录时没有值，应用规则生成值） *********************/
						if ("4".equals(String.valueOf(colMap.get("COL_GENE_METHOD"))) && ("".equals(value) || "null".equals(value))) {
							// 根据配置信息计算值
							String groupConfigStr = getConfigStr(colId, tableId, ortherConfigDataId);
							if (!"".equals(groupConfigStr)) {
								value = groupConfigStr;
								/*if ("string".equals(colType) || "clob".equals(colType)) {
									String[] eachConfigStr = groupConfigStr.split(";");// 多组配置
									// 循环算值
									String finalValue = "";// 根据配置信息计算的最终值
									for (int j = 0; j < eachConfigStr.length; j++) {
										String[] configDetial = eachConfigStr[j].split(",");// 每一组配置具体值
										// 0 - order
										// 1 - tgtColName
										// 2 - flag
										// 3 - tgtInput
										// 4 - colDropDownType
										// 5 - colIsComplement
										// 6 - colComplementNum
										String tgtColName = "";
										String flag = "";
										String tgtInput = "";
										String tgtDropDownType = "";
										String colIsComplement = "";// 是否补足
										String colComplementNum = "";// 补足位数
										String eachValue = "";// 每一组配置计算后的值
										for (int k = 0; k < configDetial.length; k++) {
											if (k == 1) {
												tgtColName = configDetial[k];
											}
											if (k == 2) {
												flag = configDetial[k];
											}
											if (k == 3) {
												tgtInput = configDetial[k];
											}
											if (k == 4) {
												tgtDropDownType = configDetial[k];
											}
											if (k == 5) {
												colIsComplement = configDetial[k];
											}
											if (k == 6) {
												colComplementNum = configDetial[k];
											}
										}
										if ("Y".equals(flag)) { // 本表字段
											if (mapObj.containsKey(tgtColName)) {
												if ("0".equals(tgtDropDownType)) {
													eachValue = String.valueOf(mapObj.get(tgtColName));
												} else if ("1".equals(tgtDropDownType) || "2".equals(tgtDropDownType)) {
													String code = String.valueOf(mapObj.get(tgtColName));// 组合字段值(lookupCode)
													
													 * // 查找组合字段ID String tgtColId = ""; List<Map<String, Object>> columnList = commTableManagerIntfsService
													 * .getCbbColumnsByTableIdAndColNameByIntfs(tableId, tgtColName); if (columnList.size() > 0) { tgtColId =
													 * String.valueOf(columnList.get(0).get("ID")); } // 查找字段下的通用代码，根据值查找对应的显示值 Map<String, Map<String, String>> colCodeMap =
													 * getColLookupCode(orgId, deptId, sysId, tableId, tgtColId); Map<String, String> lookupMap = colCodeMap.get(tgtColName);//
													 * 字段通用代码集合 // 循环集合查找code对应的name，将name赋值给组合字段值 Iterator<String> keyIt = lookupMap.keySet().iterator(); while (keyIt.hasNext()) {
													 * String lookupCode = keyIt.next(); if (code.equals(lookupCode)) { code = lookupMap.get(lookupCode); } }
													 
													eachValue = code;
												}
											}
											// 判断是否补足
											if (null != eachValue && !"".equals(eachValue) && !"null".equals(eachValue) && null != colComplementNum && !"".equals(colComplementNum) && !"0".equals(colComplementNum) && "Y".equals(colIsComplement)) {
												int lt = 0;
												lt = Integer.parseInt(colComplementNum) - eachValue.length();
												if (lt > 0) {
													for (int m = 0; m < lt; m++) {
														eachValue = "0" + eachValue;
													}
												}
											}
											if (null != tgtInput && !"".equals(tgtInput) && !"null".equals(tgtInput)) {
												eachValue = eachValue + tgtInput;
											}
										} else { // 兄弟表字段
											eachValue = tgtColName + tgtInput;
										}
										finalValue = finalValue + eachValue;
									}
									value = finalValue;// 应用组合项规则计算值
								} else if ("integer".equals(colType)) {
									String[] eachConfigStr = groupConfigStr.split(";");// 多组配置
									// 循环算值
									int finalValue = 0;// 根据配置信息计算的最终值
									for (int j = 0; j < eachConfigStr.length; j++) {
										String[] configDetial = eachConfigStr[j].split(",");// 每一组配置具体值
										// 0 - order
										// 1 - tgtColName
										// 2 - flag
										// 3 - tgtInput
										// String order = "";
										String tgtColName = "";
										String flag = "";
										String tgtInput = "";
										int eachValue = 0;// 每一组配置计算后的值
										for (int k = 0; k < configDetial.length; k++) {
											if (k == 1) {
												tgtColName = configDetial[k];
											}
											if (k == 2) {
												flag = configDetial[k];
											}
											if (k == 3) {
												tgtInput = configDetial[k];
											}
										}
										if ("Y".equals(flag)) { // 本表字段
											if (mapObj.containsKey(tgtColName)) {
												String nameValue = String.valueOf(mapObj.get(tgtColName));
												if (!"".equals(nameValue) && !"null".equals(nameValue)) {
													eachValue = Integer.parseInt(nameValue);
												}
												if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
													eachValue = eachValue + Integer.parseInt(tgtInput);
												}
											} else {
												if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
													eachValue = eachValue + Integer.parseInt(tgtInput);
												}
											}
										} else { // 兄弟表字段
											if (!"".equals(tgtColName) && !"null".equals(tgtColName)) {
												eachValue = Integer.parseInt(tgtColName);
											}
											if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
												eachValue = eachValue + Integer.parseInt(tgtInput);
											}
										}
										finalValue = finalValue + eachValue;
									}
									value = String.valueOf(finalValue);// 应用组合项规则计算值
								} else if ("float".equals(colType)) {
									String[] eachConfigStr = groupConfigStr.split(";");// 多组配置
									// 循环算值
									float finalValue = 0;// 根据配置信息计算的最终值
									for (int j = 0; j < eachConfigStr.length; j++) {
										String[] configDetial = eachConfigStr[j].split(",");// 每一组配置具体值
										// 0 - order
										// 1 - tgtColName
										// 2 - flag
										// 3 - tgtInput
										String tgtColName = "";
										String flag = "";
										String tgtInput = "";
										float eachValue = 0;// 每一组配置计算后的值
										for (int k = 0; k < configDetial.length; k++) {
											if (k == 1) {
												tgtColName = configDetial[k];
											}
											if (k == 2) {
												flag = configDetial[k];
											}
											if (k == 3) {
												tgtInput = configDetial[k];
											}
										}
										if ("Y".equals(flag)) { // 本表字段
											if (mapObj.containsKey(tgtColName)) {
												String nameValue = String.valueOf(mapObj.get(tgtColName));
												if (!"".equals(nameValue) && !"null".equals(nameValue)) {
													eachValue = Float.parseFloat(nameValue);
												}
												if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
													eachValue = eachValue + Float.parseFloat(tgtInput);
												}
											} else {
												if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
													eachValue = eachValue + Float.parseFloat(tgtInput);
												}
											}
										} else { // 兄弟表字段
											if (!"".equals(tgtColName) && !"null".equals(tgtColName)) {
												eachValue = Float.parseFloat(tgtColName);
											}
											if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
												eachValue = eachValue + Float.parseFloat(tgtInput);
											}
										}
										finalValue = finalValue + eachValue;
									}
									value = String.valueOf(finalValue);// 应用组合项规则计算值
								}
							*/}
						}
					}
				} else {
					String colGeneMethod = String.valueOf(colMap.get("COL_GENE_METHOD"));// 生成方式
					String colDropdownType = String.valueOf(colMap.get("COL_DROPDOWN_TYPE"));// 下拉类型
					String colGeneMethodRule = String.valueOf(colMap.get("COL_GENE_METHOD_RULE"));// 生成方式规则
					String colRuleName = String.valueOf(colMap.get("COL_RULE_NAME"));// 生成规则英文
					/*** 2015/07/03新增-郭亮 ****/
					// 给parentId赋值
					if ("0".equals(colGeneMethod)) {
						if (mapObj.containsKey(colName)) {
							value = String.valueOf(mapObj.get(colName));
						}
					}
					/*** 2015/07/03新增-郭亮 ****/
					if ("1".equals(colGeneMethod) && null != colGeneMethodRule) { // 默认值
						if ("1".equals(colDropdownType) || "2".equals(colDropdownType)) { // 参选、只选
							// 获取通用代码
							value = colGeneMethodRule;
						} else if ("3".equals(colDropdownType)) {
							if ("user".equals(colRuleName)) { // 选人
								if ("currentUser".equals(colGeneMethodRule)) { // 当前用户
									value = loginUserId;
								}
							} else if ("dept".equals(colRuleName)) { // 选部门
								if ("currentDept".equals(colGeneMethodRule)) { // 当前部门
									value = deptId;
								} else if ("parentDept".equals(colGeneMethodRule)) {// 当前上级部门
									value = parentDeptId;
								}
							} else if ("custom".equals(colRuleName)) { // 自定义选择
								value = getCustomValue(colGeneMethodRule, path);
							}
						} else if ("0".equals(colDropdownType)) { // 普通字段
							if ("currentUser".equals(colGeneMethodRule)) {
								value = this.getUserNameById(loginUserId);
							} else if ("currentDeptId".equals(colGeneMethodRule)) {
								value = deptId;
							} else if ("currentDeptName".equals(colGeneMethodRule)) {
								value = this.getDeptNameById(deptId);
							} else if ("currentOrg".equals(colGeneMethodRule)) {
								String orgCode = "";
								List<Map<String, Object>> fondsList = this.cbbFondsDbIntfsService.getCbbFondsDbInfoByIntfs(orgId, deptId, sysId, orgId);
								if (fondsList.size() > 0) {
									Map<String, Object> fondsMap = fondsList.get(0);
									orgCode = (String) fondsMap.get("ORG_CODE");
								}
								value = orgCode;
							} else if ("currentQzName".equals(colGeneMethodRule)) { // 当前全宗名称
								// 根据当前组织ID查找全宗名称
								List<Map<String, Object>> qzList = getQz(orgId);
								if(qzList.size() > 0){
									Map<String, Object> qzmap = qzList.get(0);
									value = String.valueOf(qzmap.get("GENERAL_NAME"));
								}else{
									value = "";
								}
							} else if ("currentQzCode".equals(colGeneMethodRule)) { // 当前全宗代码
								// 根据当前组织ID查找全宗代码
								List<Map<String, Object>> qzList = getQz(orgId);
								if(qzList.size() > 0){
									Map<String, Object> qzmap = qzList.get(0);
									value = String.valueOf(qzmap.get("GENERAL_BEN_CODE"));
								}else{
									value = "";
								}
							} else if ("currentNodeRemark".equals(colGeneMethodRule)) { // 当前数据节点备注
								// 根据节点ID查询当前数据节点备注
								List<Map<String, Object>> flList = getNodeRemarkByNodeId(nodeId);
								if(flList.size() > 0){
									Map<String, Object> flmap = flList.get(0);
									String remark = String.valueOf(flmap.get("REMARK"));//获取当前节点备注值
									if(null != remark && !"".equals(remark) && !"null".equals(remark)){
										String[] vas = remark.split(";");
										for (int j = 0; j < vas.length; j++) {
											String va = vas[j];
											String[] v = va.split("=");
											if(v.length == 2){
												if(!"".equals(v[0]) && (colName.toUpperCase()).equals(v[0].toUpperCase())){
													value = v[1];
												}
											}
										}
									}
								}else{
									value = "";
								}
							} else if ("parentDeptName".equals(colGeneMethodRule)) {// 上级部门名称
								value = this.getDeptNameById(parentDeptId);
							} else if ("parentDeptId".equals(colGeneMethodRule)) {// 上级部门ID
								value = parentDeptId;
							} else if ("parentDeptCode".equals(colGeneMethodRule)) {// 上级部门代码
								value = parentDeptCode;
							} else if ("currentDate".equals(colGeneMethodRule)) {
								java.util.Date dt = new java.util.Date();
								DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
								value = df.format(dt);
							} else {
								value = colGeneMethodRule;
							}
						}
					}
					if (listDatas.size() > 0) {
						Map<String, Object> dataMap = listDatas.get(0);
						// 字段对应选中数据对象的值
						String dataValue = String.valueOf(dataMap.get(colName));
						if ("2".equals(colGeneMethod)) { // 序列
							if ("2".equals(colDropdownType)) { // 参选
								value = dataValue + colGeneMethodRule;
							} else if ("0".equals(colDropdownType)) { // 普通字段
								if ("string".equals(colType)) {
									value = stringConfig(dataValue, colGeneMethodRule);
								} else if ("integer".equals(colType)) {
									int cdataInteger = 0;
									if (null != dataValue && !"".equals(dataValue) && !"null".equals(dataValue)) {
										cdataInteger = Integer.parseInt(dataValue);
									}
									if (null != colGeneMethodRule && !"".equals(colGeneMethodRule) && !"null".equals(colGeneMethodRule)) {
										cdataInteger = cdataInteger + Integer.parseInt(colGeneMethodRule);

									}
									if (cdataInteger != 0) {
										value = String.valueOf(cdataInteger);
									} else {
										value = "";
									}
								} else if ("float".equals(colType)) {
									float cdataFloat = 0;
									if (null != dataValue && !"".equals(dataValue) && !"null".equals(dataValue)) {
										cdataFloat = Float.parseFloat(dataValue);
									}
									if (null != colGeneMethodRule && !"".equals(colGeneMethodRule) && !"null".equals(colGeneMethodRule)) {
										cdataFloat = cdataFloat + Float.parseFloat(colGeneMethodRule);
									}
									if (cdataFloat != 0) {
										value = String.valueOf(cdataFloat);
									} else {
										value = "";
									}
								} else if ("clob".equals(colType)) {
									value = dataValue + colGeneMethodRule;
								}
							}
						} else if ("3".equals(colGeneMethod)) { // 顺带
							if ("date".equals(colType)) {
								if (null != dataValue && !"".equals(dataValue) && !"null".equals(dataValue)) {
									value = dataValue.substring(0, 10);
								} else {
									value = "";
								}
							} else {
								value = dataValue;
							}
							if ("3".equals(colDropdownType)) {
								if ("user".equals(colRuleName)) { // 选人
									value = getUserNameById(dataValue);
								} else if ("dept".equals(colRuleName)) { // 选部门
									value = getDeptNameById(dataValue);
								} else if ("custom".equals(colRuleName)) { // 自定义选择
									value = getCustomValue(dataValue, path);
								}
							}
						}
					}
					if ("4".equals(colGeneMethod)) { // 组合项
						/**************** 组合项规则修改（以前是三个字段，现在是多个字段，循环配置list<map>读取配置信息计算字段值） *********************/
						// 根据配置信息计算值
						String groupConfigStr = getConfigStr(colId, tableId, ortherConfigDataId);
						if (!"".equals(groupConfigStr)) {
							value = groupConfigStr;
							/*
							if ("string".equals(colType)) {
								String[] eachConfigStr = groupConfigStr.split(";");// 多组配置
								// 循环算值
								String finalValue = "";// 根据配置信息计算的最终值
								for (int j = 0; j < eachConfigStr.length; j++) {
									String[] configDetial = eachConfigStr[j].split(",");// 每一组配置具体值
									// 0 - order
									// 1 - tgtColName
									// 2 - flag
									// 3 - tgtInput
									String tgtColName = "";
									String flag = "";
									String tgtInput = "";
									String eachValue = "";// 每一组配置计算后的值
									for (int k = 0; k < configDetial.length; k++) {
										if (k == 1) {
											tgtColName = configDetial[k];
										}
										if (k == 2) {
											flag = configDetial[k];
										}
										if (k == 3) {
											tgtInput = configDetial[k];
										}
									}
									if ("Y".equals(flag)) { // 本表字段
										if (mapObj.containsKey(tgtColName)) {
											eachValue = String.valueOf(mapObj.get(tgtColName)) + tgtInput;
										} else {
											eachValue = tgtInput;
										}
									} else { // 兄弟表字段
										eachValue = tgtColName + tgtInput;
									}
									finalValue = finalValue + eachValue;
								}
								value = finalValue;// 应用组合项规则计算值
							} else if ("integer".equals(colType)) {
								String[] eachConfigStr = groupConfigStr.split(";");// 多组配置
								// 循环算值
								int finalValue = 0;// 根据配置信息计算的最终值
								for (int j = 0; j < eachConfigStr.length; j++) {
									String[] configDetial = eachConfigStr[j].split(",");// 每一组配置具体值
									// 0 - order
									// 1 - tgtColName
									// 2 - flag
									// 3 - tgtInput
									String tgtColName = "";
									String flag = "";
									String tgtInput = "";
									int eachValue = 0;// 每一组配置计算后的值
									for (int k = 0; k < configDetial.length; k++) {
										if (k == 1) {
											tgtColName = configDetial[k];
										}
										if (k == 2) {
											flag = configDetial[k];
										}
										if (k == 3) {
											tgtInput = configDetial[k];
										}
									}
									if ("Y".equals(flag)) { // 本表字段
										if (mapObj.containsKey(tgtColName)) {
											String nameValue = String.valueOf(mapObj.get(tgtColName));
											if (!"".equals(nameValue) || !"null".equals(nameValue)) {
												eachValue = Integer.parseInt(nameValue);
											}
											if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
												eachValue = eachValue + Integer.parseInt(tgtInput);
											}
										} else {
											if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
												eachValue = eachValue + Integer.parseInt(tgtInput);
											}
										}
									} else { // 兄弟表字段
										if (!"".equals(tgtColName) && !"null".equals(tgtColName)) {
											eachValue = Integer.parseInt(tgtColName);
										}
										if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
											eachValue = eachValue + Integer.parseInt(tgtInput);
										}
									}
									finalValue = finalValue + eachValue;
								}
								if (finalValue == 0) { // 应用组合项规则计算值
									value = String.valueOf(finalValue);
								} else {
									value = "";
								}
							} else if ("float".equals(colType)) {
								String[] eachConfigStr = groupConfigStr.split(";");// 多组配置
								// 循环算值
								float finalValue = 0;// 根据配置信息计算的最终值
								for (int j = 0; j < eachConfigStr.length; j++) {
									String[] configDetial = eachConfigStr[j].split(",");// 每一组配置具体值
									// 0 - order
									// 1 - tgtColName
									// 2 - flag
									// 3 - tgtInput
									String tgtColName = "";
									String flag = "";
									String tgtInput = "";
									float eachValue = 0;// 每一组配置计算后的值
									for (int k = 0; k < configDetial.length; k++) {
										if (k == 1) {
											tgtColName = configDetial[k];
										}
										if (k == 2) {
											flag = configDetial[k];
										}
										if (k == 3) {
											tgtInput = configDetial[k];
										}
									}
									if ("Y".equals(flag)) { // 本表字段
										if (mapObj.containsKey(tgtColName)) {
											String nameValue = String.valueOf(mapObj.get(tgtColName));
											if (!"".equals(nameValue) || !"null".equals(nameValue)) {
												eachValue = Float.parseFloat(nameValue);
											}
											if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
												eachValue = eachValue + Float.parseFloat(tgtInput);
											}
										} else {
											if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
												eachValue = eachValue + Float.parseFloat(tgtInput);
											}
										}
									} else { // 兄弟表字段
										if (!"".equals(tgtColName) && !"null".equals(tgtColName)) {
											eachValue = Float.parseFloat(tgtColName);
										}
										if (!"".equals(tgtInput) && !"null".equals(tgtInput)) {
											eachValue = eachValue + Float.parseFloat(tgtInput);
										}
									}
									finalValue = finalValue + eachValue;
								}
								if (finalValue == 0) { // 应用组合项规则计算值
									value = String.valueOf(finalValue);
								} else {
									value = "";
								}
							}
						*/}
					}
				}
				allMap.put(colName, value);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		String id = ComUtil.getId();
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("INSERT INTO " + cbbTables.getTableName() + "(");
		Iterator iteratorColName = allMap.keySet().iterator();
		while (iteratorColName.hasNext()) {
			String colName = String.valueOf(iteratorColName.next());
			if (!"LAST_UPDATE_DATE".equals(colName.toUpperCase()) && !"LAST_UPDATED_BY".equals(colName.toUpperCase()) && !"CREATION_DATE".equals(colName.toUpperCase()) && !"CREATED_BY".equals(colName.toUpperCase()) && !"LAST_UPDATE_IP".equals(colName.toUpperCase())
					&& !"VERSION".equals(colName.toUpperCase())) {
				if (!"ID".equals(colName.toUpperCase())) {
					sbSql.append(colName + ",");
				}
			}
		}
		sbSql.append("ID,");
		sbSql.append("LAST_UPDATE_DATE,");
		sbSql.append("LAST_UPDATED_BY,");
		sbSql.append("CREATION_DATE,");
		sbSql.append("CREATED_BY,");
		sbSql.append("LAST_UPDATE_IP,");
		sbSql.append("VERSION) VALUES (");
		iteratorColName = allMap.keySet().iterator();
		while (iteratorColName.hasNext()) {
			// String parentId = String.valueOf(allMap.get("PARENT_ID"));
			String colName = String.valueOf(iteratorColName.next());
			String value = String.valueOf(allMap.get(colName));
			if (!"LAST_UPDATE_DATE".equals(colName.toUpperCase()) && !"LAST_UPDATED_BY".equals(colName.toUpperCase()) && !"CREATION_DATE".equals(colName.toUpperCase()) && !"CREATED_BY".equals(colName.toUpperCase()) && !"LAST_UPDATE_IP".equals(colName.toUpperCase())
					&& !"VERSION".equals(colName.toUpperCase())) {
				if (!"ID".equals(colName.toUpperCase())) {
					String colType = "";
					colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
					if ("string".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sbSql.append("'',");
						} else {
							// 单引号的转换
							value = value.replaceAll("'", "' || chr(39) || '");
							value = "'" + value + "'";
							sbSql.append(value + ",");
						}
					} else if ("integer".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sbSql.append(" NULL,");
						} else {
							sbSql.append(value + ",");
						}
					} else if ("date".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sbSql.append("NULL,");
						} else {
							if (value.length() <= 10) {
								sbSql.append("TO_DATE('" + value + "','yyyy-MM-dd'),");
							} else {
								sbSql.append("TO_DATE('" + value + "','yyyy-MM-dd hh24:mi:ss'),");
							}
						}
					} else if ("float".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sbSql.append("NULL,");
						} else {
							sbSql.append(value + ",");
						}
					} else if ("blob".equals(colType)) {
						sbSql.append("NULL,");
					} else if ("clob".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							sbSql.append("NULL,");
						} else {
							sbSql.append("'" + value + "',");
						}
					}
				}
			}
		}
		sbSql.append("'" + id + "',");
		sbSql.append("SYSDATE,");
		sbSql.append("'" + loginUserId + "',");
		sbSql.append("SYSDATE,");
		sbSql.append("'" + loginUserId + "',");
		sbSql.append("'" + loginIp + "',");
		sbSql.append("0)");
		// JDBC实现新增
		executeJdbc(sysId, sbSql.toString(), "insert", orgId, deptId, modleName);
		/*** 2015/07/03新增-郭亮 ***/
		String parentId = String.valueOf(mapObj.get("PARENT_ID"));
		String ajDataId = "";
		if (null != parentId && !"".equals(parentId) && !"null".equals(parentId)) { // 文件级数据操作
			ajDataId = parentId;
		} else { // 组卷时新增案卷
			ajDataId = id;
		}
		// 判断并执行反更新操作
		String wjIds = String.valueOf(param.get("wjIds"));// 文件数据ID串
		String nodeId = String.valueOf(mapObj.get("NODE_ID"));
		if (null != wjIds && null != nodeId && !"null".equals(wjIds) && !"".equals(wjIds) && !"null".equals(nodeId) && !"".equals(nodeId)) {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("modleName", modleName);
			updateAjDataByWjdataByInfs(tableId, ajDataId, orgId, deptId, sysId, nodeId, wjIds, params);
			/*** 2015/07/03新增-郭亮 ***/
		}
		// 反更新案卷信息(统计生成)
		if (null != parentId && !"".equals(parentId) && !"null".equals(parentId) && null != nodeId && !"null".equals(nodeId) && !"".equals(nodeId)) {
			ajDataId = String.valueOf(param.get("ajDataId"));
			// 判断并执行反更新操作(不是组卷操作，文件ID串传空)
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("modleName", modleName);
			updateAjDataByWjdataByInfs(tableId, parentId, orgId, deptId, sysId, nodeId, "", params);
		}
		// SanXiaFiles create by zhaoxiaolong 案卷级和件级在新增完成后，更新档号字段值
        if(combinatorialTermId!=""){
            String archiveCode = this.getConfigStr(combinatorialTermId,tableId,id);
            StringBuffer upSql = new StringBuffer();
            upSql.append("UPDATE "+cbbTables.getTableName()+" SET ARCHIVE_CODE = '"+archiveCode+"' WHERE ID = '"+id+"'");
            this.jdbcAvicit.getJdbcTemplate().update(upSql.toString());
        }
		return id;
	}

	/***
	 * 判断是否需要更新案卷级数据（当返回值为空时不进行案卷级数据更新）
	 *
	 * @author 郭亮
	 * @param nodeId
	 *            必填
	 * @param tableId
	 *            必填
	 * @return 案卷级表Id
	 * @throws Exception
	 */
	public String isUpdateAjData(String nodeId, String tableId) throws Exception {
		String ajTabId = ""; // 返回值(案卷级表ID)
		if (null == nodeId && "".equals(nodeId)) {
			throw new Exception("调用接口时，nodeId参数不存在，请检查！");
		}
		if (null == tableId && "".equals(tableId)) {
			throw new Exception("调用接口时，tableId参数不存在，请检查！");
		}
		// 根据nodeId判结构
		String isSeconSql = "SELECT COUNT(*) FROM CBB_TAB_NODE T WHERE T.NODE_ID = '" + nodeId + "'";
		List<Object> isSecondList = this.hibernateDao.findBySQL(isSeconSql);
		if (isSecondList.size() > 0) {
			String structure = String.valueOf(isSecondList.get(0)); // 节点结构
			if ("2".equals(structure)) { // 2级结构
				if (null != tableId && !"".equals(tableId)) { // 判断表类型
					String tabTypeSql = "SELECT T.TAB_ORDER FROM CBB_TAB_NODE T WHERE T.TABLE_ID = '" + tableId + "'";
					List<Object> tabTypeList = this.hibernateDao.findBySQL(tabTypeSql);
					if (tabTypeList.size() > 0) {
						String tabType = String.valueOf(tabTypeList.get(0));
						if ("2".equals(tabType)) { // 文件级表数据
							// 根据nodeId，wjTabId查找ajTabId
							String ajTabSql = "SELECT T.TABLE_ID FROM CBB_TAB_NODE T WHERE T.NODE_ID = '" + nodeId + "' AND T.TABLE_ID <> '" + tableId + "'";
							List<Object> ajTabIdList = this.hibernateDao.findBySQL(ajTabSql);
							if (ajTabIdList.size() > 0) {
								ajTabId = String.valueOf(ajTabIdList.get(0));
							}
						}
					}
				}
			}
		}
		return ajTabId;
	}

	/***
	 * 根据统计信息计算值
	 *
	 * @author 郭亮
	 * @param sourceTabId
	 *            案卷级（源）表Id，必填
	 * @param tgtTabId
	 *            文件级（配置字段）表Id，必填
	 * @param colId1
	 *            第一个字段Id，非必填
	 * @param colId2
	 *            第二个字段Id，非必填
	 * @param colId3
	 *            第三个字段Id，非必填
	 * @param input1
	 *            第一个固定值，非必填
	 * @param input2
	 *            第二个固定值，非必填
	 * @param operation
	 *            运算方式，必填
	 * @param colType
	 *            案卷级（源）字段类型，必填
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param ajDataId
	 *            案卷级数据ID
	 * @param wjDataIds
	 *            文件级数据ID串（组卷新增案卷时有值）
	 * @return
	 * @throws Exception
	 */
	public String getValueByconfig(String sourceTabId, String tgtTabId, String colId1, String colId2, String colId3, String input1, String input2, String operation, String colType, String orgId, String deptId, String sysId, String ajDataId, String wjDataIds) throws Exception {
		String value = ""; // 最终计算结果
		String tgtTabName = ""; // 文件级表名
		String colName1 = ""; // 第一个字段名
		String colName2 = ""; // 第二个字段名
		String colName3 = ""; // 第三个字段名
		// 获取案卷级表名
		if (null == sourceTabId || "".equals(sourceTabId) || "null".equals(sourceTabId)) {
			throw new Exception("调用接口时，sourceTabId参数不存在，请检查！");
		}
		// 获取文件级表名
		if (null != tgtTabId && !"".equals(tgtTabId) || !"null".equals(tgtTabId)) {
			List<Map<String, Object>> tabList = commTableManagerIntfsService.getCbbTableAndColumnsByTabIdByIntfs(tgtTabId);
			if (tabList.size() > 0) {
				tgtTabName = String.valueOf(tabList.get(0).get("TABLE_NAME"));
			}
		} else {
			throw new Exception("调用接口时，tgtTabId参数不存在，请检查！");
		}
		// 判断运算方式是否为空
		if (null == operation || "".equals(operation) || "null".equals(operation)) {
			throw new Exception("调用接口时，operation参数不存在，请检查！");
		}
		// 判断源字段类型是否为空
		if (null == colType || "".equals(colType) || "null".equals(colType)) {
			throw new Exception("调用接口时，colType参数不存在，请检查！");
		}
		if (null == orgId || "".equals(orgId) || "null".equals(orgId)) {
			throw new Exception("调用接口时，orgId参数不存在，请检查！");
		}
		if (null == deptId || "".equals(deptId) || "null".equals(deptId)) {
			throw new Exception("调用接口时，deptId参数不存在，请检查！");
		}
		if (null == sysId || "".equals(sysId) || "null".equals(sysId)) {
			throw new Exception("调用接口时，sysId参数不存在，请检查！");
		}
		// 获取字段名
		if (null != colId1 && !"".equals(colId1) && !"null".equals(colId1)) { // 第一个
			List<Map<String, Object>> listCol = commTableManagerIntfsService.getCbbColumnsByColIdByIntfs(colId1);
			if (listCol.size() > 0) {
				colName1 = String.valueOf(listCol.get(0).get("COL_NAME"));
			}
		}
		if (null != colId2 && !"".equals(colId2) && !"null".equals(colId2)) { // 第二个
			List<Map<String, Object>> listCol = commTableManagerIntfsService.getCbbColumnsByColIdByIntfs(colId2);
			if (listCol.size() > 0) {
				colName2 = String.valueOf(listCol.get(0).get("COL_NAME"));
			}
		}
		if (null != colId3 && !"".equals(colId3) && !"null".equals(colId3)) { // 第三个
			List<Map<String, Object>> listCol = commTableManagerIntfsService.getCbbColumnsByColIdByIntfs(colId3);
			if (listCol.size() > 0) {
				colName3 = String.valueOf(listCol.get(0).get("COL_NAME"));
			}
		}
		// 根据运算方式和字段类型计算
		String colValue1 = ""; // 第一个字段值
		String colValue2 = ""; // 第二个字段值
		String colValue3 = ""; // 第三个字段值
		// 对固定值进行验证
		if (input1.equals("null")) {
			input1 = "";
		}
		if (input2.equals("null")) {
			input2 = "";
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接

			statement = conn.createStatement();

			String wjIds = wjDataIds;// 文件数据ID串（组卷新增案卷时有值）
			String wjIdsTemp = "";
			if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
				// 对ID串做处理，拼上单引号在sql语句的in中使用
				String[] ids = wjIds.split(",");
				for (int i = 0; i < ids.length; i++) {
					wjIdsTemp = wjIdsTemp + ",'" + ids[i] + "'";
				}
				if (!"".equals(wjIdsTemp) && !"null".equals(wjIdsTemp)) {
					wjIds = wjIdsTemp.substring(1);
				} else {
					wjIds = "";
				}
			}
			if ("1".equals(operation)) { // 第一个
				// 调用接口方法查询文件级数据
				List<Map<String, Object>> objList = new ArrayList<Map<String, Object>>();
				// 对于组卷和普通算值做判断
				if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
					objList = getTableFieldsAndDatasBySearchByNoChangeByIntfs(orgId, deptId, sysId, tgtTabId, "0", "0", "AND ID IN (" + wjIds + ")", new HashMap<String, Object>());
				} else { // 普通算值
					objList = getTableFieldsAndDatasBySearchByNoChangeByIntfs(orgId, deptId, sysId, tgtTabId, "0", "0", "AND PARENT_ID = '" + ajDataId + "'", new HashMap<String, Object>());
				}
				// 根据运算式获取某一条数据
				Map<String, Object> objMap = new HashMap<String, Object>();
				if (objList.size() > 0) {
					objMap = objList.get(0);
				}
				// 根据统计字段获取对应值
				if (!"".equals(colName1)) { // 第一个字段值
					colValue1 = String.valueOf(objMap.get(colName1));
				}
				if (!"".equals(colName2)) { // 第二个字段值
					colValue2 = String.valueOf(objMap.get(colName2));
				}
				if (!"".equals(colName3)) { // 第三个字段值
					colValue3 = String.valueOf(objMap.get(colName3));
				}
				// 对"null"进行处理
				if (null == colValue1 || "null".equals(colValue1)) {
					colValue1 = "";
				}
				if (null == colValue2 || "null".equals(colValue2)) {
					colValue2 = "";
				}
				if (null == colValue3 || "null".equals(colValue3)) {
					colValue3 = "";
				}
				// 根据字段类型进行字段值拼接
				if ("string".equals(colType)) { // 字符串
					value = colValue1 + input1 + colValue2 + input2 + colValue3;
				} else if ("integer".equals(colType)) {
					value = String.valueOf(Integer.parseInt(colValue1.equals("") ? "0" : colValue1) + Integer.parseInt(input1.equals("") ? "0" : input1) + Integer.parseInt(colValue2.equals("") ? "0" : colValue2) + Integer.parseInt(input2.equals("") ? "0" : input2)
							+ Integer.parseInt(colValue3.equals("") ? "0" : colValue3));
				} else if ("float".equals(colType)) {
					value = String.valueOf(Float.parseFloat(colValue1.equals("") ? "0" : colValue1) + Float.parseFloat(input1.equals("") ? "0" : input1) + Float.parseFloat(colValue2.equals("") ? "0" : colValue2) + Float.parseFloat(input2.equals("") ? "0" : input2)
							+ Float.parseFloat(colValue3.equals("") ? "0" : colValue3));
				} else if ("date".equals(colType)) {
					// date型字段只允许配置一个字段
					value = colValue1;
					// 对date型数据做处理（执行sql转换时没有时分秒）
					if (!"".equals(value) && !"null".equals(value) && null != value) {
						value = value.substring(0, 10);
					}
				} else if ("clob".equals(colType)) {
					value = colValue1 + input1 + colValue2 + input2 + colValue3;
				} else if ("blob".equals(colType)) {
					value = colValue1 + input1 + colValue2 + input2 + colValue3;
				}
			} else if ("2".equals(operation)) { // 最后一个
				// 调用接口方法查询文件级数据
				List<Map<String, Object>> objList = new ArrayList<Map<String, Object>>();
				// 对于组卷和普通算值做判断
				if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
					objList = getTableFieldsAndDatasBySearchByNoChangeByIntfs(orgId, deptId, sysId, tgtTabId, "0", "0", "AND ID IN (" + wjIds + ")", new HashMap<String, Object>());
				} else { // 普通算值
					objList = getTableFieldsAndDatasBySearchByNoChangeByIntfs(orgId, deptId, sysId, tgtTabId, "0", "0", "AND PARENT_ID = '" + ajDataId + "'", new HashMap<String, Object>());
				}
				// 根据运算式获取某一条数据
				Map<String, Object> objMap = new HashMap<String, Object>();
				if (objList.size() > 0) {
					objMap = objList.get(objList.size() - 1);
				}
				// 根据统计字段获取对应值
				if (!"".equals(colName1)) { // 第一个字段值
					colValue1 = String.valueOf(objMap.get(colName1));
				}
				if (!"".equals(colName2)) { // 第二个字段值
					colValue2 = String.valueOf(objMap.get(colName2));
				}
				if (!"".equals(colName3)) { // 第三个字段值
					colValue3 = String.valueOf(objMap.get(colName3));
				}
				// 对"null"进行处理
				if (null == colValue1 || "null".equals(colValue1)) {
					colValue1 = "";
				}
				if (null == colValue2 || "null".equals(colValue2)) {
					colValue2 = "";
				}
				if (null == colValue3 || "null".equals(colValue3)) {
					colValue3 = "";
				}
				// 根据字段类型进行字段值拼接
				if ("string".equals(colType)) { // 字符串
					value = colValue1 + input1 + colValue2 + input2 + colValue3;
				} else if ("integer".equals(colType)) {
					value = String.valueOf(Integer.parseInt(colValue1.equals("") ? "0" : colValue1) + Integer.parseInt(input1.equals("") ? "0" : input1) + Integer.parseInt(colValue2.equals("") ? "0" : colValue2) + Integer.parseInt(input2.equals("") ? "0" : input2)
							+ Integer.parseInt(colValue3.equals("") ? "0" : colValue3));
				} else if ("float".equals(colType)) {
					value = String.valueOf(Float.parseFloat(colValue1.equals("") ? "0" : colValue1) + Float.parseFloat(input1.equals("") ? "0" : input1) + Float.parseFloat(colValue2.equals("") ? "0" : colValue2) + Float.parseFloat(input2.equals("") ? "0" : input2)
							+ Float.parseFloat(colValue3.equals("") ? "0" : colValue3));
				} else if ("date".equals(colType)) {
					// date型字段只允许配置一个字段
					value = colValue1;
					// 对date型数据做处理（执行sql转换时没有时分秒）
					if (!"".equals(value) && !"null".equals(value) && null != value) {
						value = value.substring(0, 10);
					}
				} else if ("clob".equals(colType)) {
					value = colValue1 + input1 + colValue2 + input2 + colValue3;
				} else if ("blob".equals(colType)) {
					value = colValue1 + input1 + colValue2 + input2 + colValue3;
				}
			} else if ("3".equals(operation)) { // 最大的
				// 根据字段类型拼接查询sql
				if ("string".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MAX(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" || '" + input1 + "'");
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" || T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" || '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" || T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				} else if ("integer".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MAX(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" + " + input1);
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" + T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" + '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" + T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				} else if ("float".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MAX(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" + " + input1);
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" + T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" + '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" + T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				} else if ("date".equals(colType)) {
					// date型字段只允许配置一个字段
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MAX(T." + colName1.toUpperCase());
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
						// 对date型数据做处理（执行sql转换时没有时分秒）
						if (!"".equals(value) && !"null".equals(value) && null != value) {
							value = value.substring(0, 10);
						}
					}
				} else if ("clob".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MAX(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" || '" + input1 + "'");
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" || T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" || '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" || T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				} else if ("blob".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MAX(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" || '" + input1 + "'");
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" || T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" || '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" || T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				}
			} else if ("4".equals(operation)) { // 最小的
				// 根据字段类型拼接查询sql
				if ("string".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MIN(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" || '" + input1 + "'");
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" || T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" || '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" || T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				} else if ("integer".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MIN(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" + " + input1);
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" + T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" + '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" + T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				} else if ("float".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MIN(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" + " + input1);
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" + T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" + '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" + T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				} else if ("date".equals(colType)) {
					// date型字段只允许配置一个字段
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MIN(T." + colName1.toUpperCase());
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
						// 对date型数据做处理（执行sql转换时没有时分秒）
						if (!"".equals(value) && !"null".equals(value) && null != value) {
							value = value.substring(0, 10);
						}
					}
				} else if ("clob".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MIN(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" || '" + input1 + "'");
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" || T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" || '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" || T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				} else if ("blob".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT MIN(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" || '" + input1 + "'");
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" || T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" || '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" || T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				}
			} else if ("5".equals(operation)) { // 求和
				if ("integer".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT SUM(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" + " + input1);
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" + T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" + '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" + T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					//如果是ARCHIVE_PAGE_NUM（页数）字段，需要判文件类型的值为“图纸”时，页数才进行统计
					if(colName1.equals("ARCHIVE_PAGE_NUM")){
						dataSqlBuf.append(" AND T.WJLX='图纸'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				} else if ("float".equals(colType)) {
					StringBuffer dataSqlBuf = new StringBuffer("SELECT SUM(");
					if (!"".equals(colName1)) {
						dataSqlBuf.append("T." + colName1.toUpperCase());
						if (!"".equals(input1)) {
							dataSqlBuf.append(" + " + input1);
						}
					}
					if (!"".equals(colName2)) {
						if (!"".equals(colName1)) {
							dataSqlBuf.append(" + T." + colName2.toUpperCase());
						} else {
							dataSqlBuf.append("T." + colName2.toUpperCase());
						}
						if (!"".equals(input2)) {
							dataSqlBuf.append(" + '" + input2 + "'");
						}
					}
					if (!"".equals(colName3)) {
						if ("".equals(colName1) && "".equals(colName2)) {
							dataSqlBuf.append("T." + colName3.toUpperCase());
						} else {
							dataSqlBuf.append(" + T." + colName3.toUpperCase());
						}
					}
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 组卷算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.ID IN (" + wjIds + ")");
					} else { // 普通算值
						dataSqlBuf.append(") AS A FROM " + tgtTabName.toUpperCase() + " T WHERE T.PARENT_ID = '" + ajDataId + "'");
					}
					// 执行查询sql
					rs = statement.executeQuery(dataSqlBuf.toString());
					// 获取结果集中的数据
					while (rs.next()) {
						value = rs.getString("A");
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return value;
	}

	/***
	 * 根据文件级数据更新案卷级数据（统计生成应用）
	 *
	 * @author 郭亮
	 * @param tableId
	 *            当前操作表ID（必填）
	 * @param ajDataId
	 *            案卷级表ID （必填）
	 * @param orgId
	 *            案卷级数据记录ID （非必填）
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param wjIds
	 *            文件数据ID串，组卷操作时有值
	 * @throws Exception
	 */
	@Override
	public void updateAjDataByWjdataByInfs(String tableId, String ajDataId, String orgId, String deptId, String sysId, String nodeId, String wjIds, Map<String, Object> params) throws Exception {
		String modleName = "XXX模块";
		if (params.containsKey("modleName")) {
			modleName = (String) params.get("modleName");
		}
		String markerUpdate = "";
		if (params.containsKey("markerUpdate")) {
			markerUpdate = (String) params.get("markerUpdate");
		}
		// 判断参数
		if (null == tableId || "".equals(tableId) || "null".equals(tableId)) {
			throw new Exception("调用接口时，tableId参数不存在，请检查！");
		}
		if (null == orgId || "".equals(orgId) || "null".equals(orgId)) {
			throw new Exception("调用接口时，orgId参数不存在，请检查！");
		}
		if (null == deptId || "".equals(deptId) || "null".equals(deptId)) {
			throw new Exception("调用接口时，deptId参数不存在，请检查！");
		}
		if (null == sysId || "".equals(sysId) || "null".equals(sysId)) {
			throw new Exception("调用接口时，sysId参数不存在，请检查！");
		}
		if (null == nodeId || "".equals(nodeId) || "null".equals(nodeId)) {
			throw new Exception("调用接口时，nodeId参数不存在，请检查！");
		}
		String ajTabId = isUpdateAjData(nodeId, tableId);// 判断是否为文件操作
		if ((null != ajTabId && !"".equals(ajTabId) && !"null".equals(ajTabId)) || (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds))) { // 1、案卷下的文件操作执行反更新操作；2、组卷新增案卷级数据进行反更新操作
			String[] ajIds = ajDataId.split(",");
			for (int k = 0; k < ajIds.length; k++) {
				String ajId = ajIds[k];
				if ((null != ajId && !"".equals(ajId) && !"null".equals(ajId)) || (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds))) {
					// 1、案卷下的文件操作执行反更新操作；2、组卷新增案卷级数据进行反更新操作
					// 根据ajTabId查找统计生成配置信息的sourceColumnId
					String sourceColIdSql = "";
					if (null != ajTabId && !"".equals(ajTabId) && !"null".equals(ajTabId)) { // 文件级数据操作
						sourceColIdSql = "SELECT T.SOURCE_COLUMN_ID FROM CBB_TAB_COL_CONFIG_GROUP T WHERE T.SOURCE_TABLE_ID = '" + ajTabId + "' GROUP BY T.SOURCE_COLUMN_ID";
					} else { // 组卷时新增案卷操作
						sourceColIdSql = "SELECT T.SOURCE_COLUMN_ID FROM CBB_TAB_COL_CONFIG_GROUP T WHERE T.SOURCE_TABLE_ID = '" + tableId + "' GROUP BY T.SOURCE_COLUMN_ID";
					}
					List<Object> sourceColIdList = this.hibernateDao.findBySQL(sourceColIdSql);
					if (sourceColIdList.size() > 0) {
						for (int i = 0; i < sourceColIdList.size(); i++) {
							if (null != ajTabId && !"".equals(ajTabId) && !"null".equals(ajTabId)) { // 1、案卷下的文件操作
								// 循环查找每一个案卷级字段的统计生成配置信息
								String sourceColId = String.valueOf(sourceColIdList.get(i)); // 案卷级字段ID
								List<Map<String, Object>> listCol = commTableManagerIntfsService.getCbbColumnsByColIdByIntfs(sourceColId);
								String colType = String.valueOf(listCol.get(0).get("COL_TYPE"));
								String colName = String.valueOf(listCol.get(0).get("COL_NAME"));
								String configSql = "SELECT T.GROUP_ORDER,T.TARGET_TABLE_ID,T.TARGET_COLUMN_ID,T.TARGET_INPUT,T.TARGET_COLUMN_OPERATION FROM CBB_TAB_COL_CONFIG_GROUP T WHERE T.SOURCE_TABLE_ID = '" + ajTabId + "' AND T.SOURCE_COLUMN_ID = '" + sourceColId + "'";
								List<Object[]> configList = this.hibernateDao.findBySQL(configSql);
								if (configList.size() > 0) {
									String order = "";
									String tgtTabId = "";
									String colId1 = "";
									String colId2 = "";
									String colId3 = "";
									String input1 = "";
									String input2 = "";
									String operation = "";
									for (int j = 0; j < configList.size(); j++) {
										order = String.valueOf(configList.get(j)[0]);
										tgtTabId = String.valueOf(configList.get(j)[1]);
										operation = String.valueOf(configList.get(j)[4]);
										if ("1".equals(order)) {
											colId1 = String.valueOf(configList.get(j)[2]);
											input1 = String.valueOf(configList.get(j)[3]);
										} else if ("2".equals(order)) {
											colId2 = String.valueOf(configList.get(j)[2]);
											input2 = String.valueOf(configList.get(j)[3]);
										} else if ("3".equals(order)) {
											colId3 = String.valueOf(configList.get(j)[2]);
										}
									}
									// 读取资源文件对特殊字段做处理
									Map<String, Object> mapObj = new HashMap<String, Object>();
									// 直接传入计算值(此处为普通算值，文件级数据ID串传空串)
									String newValue = getValueByconfig(ajTabId, tgtTabId, colId1, colId2, colId3, input1, input2, operation, colType, orgId, deptId, sysId, ajId, "");
									// 对“null”处理
									if (null == newValue || "null".equals(newValue)) {
										newValue = "";
									}
									//zcl 2019-09-23 整理归档与档案整理附图数量为空时，卷的附图数量归0
									if("1".equals(markerUpdate) && "FTSL".equals(colName) && StringUtils.isEmpty(newValue)){
										newValue = "0";
									}
									// 构造更新map
									mapObj.put(colName, newValue);
									Map<String, Object> param = new HashMap<String, Object>();
									param.put("modleName", modleName);
									// 更新案卷级数据
									updateRecordByDataIdByIntfs(orgId, deptId, sysId, nodeId, ajTabId, mapObj, ajId, param);
								}
							}
							if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) { // 2、组卷案卷新增操作(只针对隐藏字段应用)
								// 循环查找每一个案卷级字段的统计生成配置信息
								String sourceColId = String.valueOf(sourceColIdList.get(i)); // 案卷级字段ID
								List<Map<String, Object>> listCol = commTableManagerIntfsService.getCbbColumnsByColIdByIntfs(sourceColId);
								String colType = String.valueOf(listCol.get(0).get("COL_TYPE"));
								String colName = String.valueOf(listCol.get(0).get("COL_NAME"));
								String colIsDisplay = String.valueOf(listCol.get(0).get("COL_IS_DISPLAY"));// 是否可见
								String colIsVisible = String.valueOf(listCol.get(0).get("COL_IS_VISIBLE"));// 是否显示（添加/编辑）
								String colIsEdit = String.valueOf(listCol.get(0).get("COL_IS_EDIT"));// 是否可编辑（添加/编辑）
								if (!("Y".equals(colIsDisplay) && "Y".equals(colIsVisible) && "Y".equals(colIsEdit))) { // 隐藏字段
									String configSql = "SELECT T.GROUP_ORDER,T.TARGET_TABLE_ID,T.TARGET_COLUMN_ID,T.TARGET_INPUT,T.TARGET_COLUMN_OPERATION FROM CBB_TAB_COL_CONFIG_GROUP T WHERE T.SOURCE_TABLE_ID = '" + tableId + "' AND T.SOURCE_COLUMN_ID = '" + sourceColId + "'";
									List<Object[]> configList = this.hibernateDao.findBySQL(configSql);
									if (configList.size() > 0) {
										String order = "";
										String tgtTabId = "";
										String colId1 = "";
										String colId2 = "";
										String colId3 = "";
										String input1 = "";
										String input2 = "";
										String operation = "";
										for (int j = 0; j < configList.size(); j++) {
											order = String.valueOf(configList.get(j)[0]);
											tgtTabId = String.valueOf(configList.get(j)[1]);
											operation = String.valueOf(configList.get(j)[4]);
											if ("1".equals(order)) {
												colId1 = String.valueOf(configList.get(j)[2]);
												input1 = String.valueOf(configList.get(j)[3]);
											} else if ("2".equals(order)) {
												colId2 = String.valueOf(configList.get(j)[2]);
												input2 = String.valueOf(configList.get(j)[3]);
											} else if ("3".equals(order)) {
												colId3 = String.valueOf(configList.get(j)[2]);
											}
										}
										Map<String, Object> mapObj = new HashMap<String, Object>();
										// 直接传入计算值(此处为普通算值，文件级数据ID串传空串)
										String newValue = getValueByconfig(tableId, tgtTabId, colId1, colId2, colId3, input1, input2, operation, colType, orgId, deptId, sysId, ajId, wjIds);
										// 对“null”处理
										if (null == newValue || "null".equals(newValue)) {
											newValue = "";
										}
										// 构造更新map
										mapObj.put(colName, newValue);
										Map<String, Object> param = new HashMap<String, Object>();
										param.put("modleName", modleName);
										// 更新案卷级数据
										updateRecordByDataIdByIntfs(orgId, deptId, sysId, nodeId, tableId, mapObj, ajId, param);
									}
								}
							}
						}
					}
				}
			}
		}
	}

	/***
	 * 根据数据ID修改业务数据状态等（单一数据修改,带有文件级反更新新案卷级操作,编辑文件或案卷数据时使用）
	 *
	 * @author 郭亮
	 * @param orgId
	 *            必填
	 * @param deptId
	 *            必填
	 * @param sysId
	 *            必填
	 * @param nodeId
	 *            必填
	 * @param tableId
	 *            必填
	 * @param mapObj
	 *            必填
	 * @param dataId
	 *            必填
	 * @param param
	 *            参数MAP[p1：key='ajDataId'，value：String非必填（案卷级数据ID）]
	 *            参数MAP[p2：key='modleName'，value：模块名称）]
	 * @throws Exception
	 */
	@Override
	public void updateRecordByDataIdWithUpdateAjByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, Map<String, Object> mapObj, String dataId, Map<String, Object> param) throws Exception {
	    String modleName = "XXX模块";
		if (param.containsKey("modleName")) {
			modleName = (String) param.get("modleName");
		}
	    String markerUpdate = "";
		if (param.containsKey("markerUpdate")) {
			markerUpdate = (String) param.get("markerUpdate");
		}
		if (null == orgId || "".equals(orgId)) {
			throw new Exception("调用接口时，orgId参数不存在，请检查！");
		}
		if (null == deptId || "".equals(deptId)) {
			throw new Exception("调用接口时，deptId参数不存在，请检查！");
		}
		if (null == sysId || "".equals(sysId)) {
			throw new Exception("调用接口时，sysId参数不存在，请检查！");
		}
		if (null == nodeId || "".equals(nodeId)) {
			throw new Exception("调用接口时，nodeId参数不存在，请检查！");
		}
		if (null == tableId || "".equals(tableId)) {
			throw new Exception("调用接口时，tableId参数不存在，请检查！");
		}
		if (null == mapObj || mapObj.size() == 0) {
			throw new Exception("调用接口时，mapObj参数不存在，请检查！");
		}
		if (null == dataId || "".equals(dataId)) {
			throw new Exception("调用接口时，dataId参数不存在，请检查！");
		}

		CbbTables cbbTables = getCbbTablesById(tableId);
		StringBuffer sbSqlup = new StringBuffer();
		sbSqlup.append("UPDATE " + cbbTables.getTableName() + " SET ");
		Iterator iterator = mapObj.keySet().iterator();
		while (iterator.hasNext()) {
			String colName = String.valueOf(iterator.next());
			String value = String.valueOf(mapObj.get(colName));
			String colType = "";
			colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
			if ("string".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlup.append(colName + " = NULL,");
				} else {
					// 单引号的转换
					value = value.replaceAll("'", "' || chr(39) || '");
					sbSqlup.append(colName + "='" + value + "',");
				}
			} else if ("integer".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlup.append(colName + " = NULL,");
				} else {
					sbSqlup.append(colName + "=" + value + ",");
				}
			} else if ("date".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlup.append(colName + " = NULL,");
				} else {
					sbSqlup.append(colName + "= TO_DATE('" + value + "','yyyy-MM-dd hh24:mi:ss'),");
				}
			} else if ("float".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlup.append(colName + " = NULL,");
				} else {
					sbSqlup.append(colName + "=" + value + ",");
				}
			} else if ("blob".equals(colType)) {
				sbSqlup.append(colName + " = NULL,");
			} else if ("clob".equals(colType)) {
				if (value == null || "".equals(value) || "null".equals(value)) {
					sbSqlup.append(colName + " = NULL,");
				} else {
					sbSqlup.append(colName + "= '" + value + "',");
				}
			}
		}
		String upSql = sbSqlup.substring(0, sbSqlup.length() - 1);
		upSql = upSql + " WHERE ID = '" + dataId + "'";
		if (mapObj.size() != 0) {
			// JDBC实现更新
			executeJdbc(sysId, upSql, "update", orgId, deptId, modleName);
			String ajDataId = "";
			if (null != param && param.containsKey("ajDataId")) {
				ajDataId = String.valueOf(param.get("ajDataId"));
				// 判断并执行反更新操作(不是组卷操作，文件ID串传空)
				Map<String, Object> params = new HashMap<String, Object>();
				params.put("modleName", modleName);
				params.put("markerUpdate", markerUpdate);
				updateAjDataByWjdataByInfs(tableId, ajDataId, orgId, deptId, sysId, nodeId, "", params);
			}
		}
		// SanXiaFiles create by zhaoxiaolong 更新档号 Run
		/*List<Map<String, Object>> listCname = commTableManagerIntfsService.getCbbTabColumnsByIsAllByIntfs(orgId, deptId, sysId, tableId, "Y");// 所有字段名称集合
		String archiveCodeId = "";
		if(listCname.size()>0){
			for (int i = 0 ;i<listCname.size();i++){
				Map<String,Object> objectMap = listCname.get(i);
				if(objectMap.get("COL_NAME").toString().equals("ARCHIVE_CODE")){
					archiveCodeId = String.valueOf(objectMap.get("ID"));
					break;
				}
			}
			String archiveCode = this.getConfigStr(archiveCodeId,tableId,dataId);
			mapObj.put("ARCHIVE_CODE",archiveCode);
		}*/
		// end
	}

	/***
	 * 根据IDS批量修改业务数据状态等（批量数据修改,带有反更新操作）
	 *
	 * @author 郭亮
	 * @param orgId
	 *            必填
	 * @param deptId
	 *            必填
	 * @param sysId
	 *            必填
	 * @param nodeId
	 *            必填
	 * @param tableId
	 *            必填
	 * @param mapObj
	 *            必填
	 * @param dataIds
	 *            必填
	 * @param param
	 *            参数MAP[p1：key='ajDataId'，value：String非必填（案卷级数据ID）]
	 * @throws Exception
	 */
	@Override
	public void updateRecordByDataIdsWithUpdateAjByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, Map<String, Object> mapObj, String dataIds, Map<String, Object> param) throws Exception {
		String modleName = "XXX模块";
		if (param.containsKey("modleName")) {
			modleName = (String) param.get("modleName");
		}
		String markerUpdate = "";
		if (param.containsKey("markerUpdate")) {
			markerUpdate = (String) param.get("markerUpdate");
		}
		// 验证参数是否正确
		if (null == orgId || "".equals(orgId)) {
			throw new Exception("调用接口时，orgId参数不存在，请检查！");
		}
		if (null == deptId || "".equals(deptId)) {
			throw new Exception("调用接口时，deptId参数不存在，请检查！");
		}
		if (null == sysId || "".equals(sysId)) {
			throw new Exception("调用接口时，sysId参数不存在，请检查！");
		}
		if (null == nodeId || "".equals(nodeId)) {
			throw new Exception("调用接口时，nodeId参数不存在，请检查！");
		}
		if (null == tableId || "".equals(tableId)) {
			throw new Exception("调用接口时，tableId参数不存在，请检查！");
		}
		if (null == mapObj || mapObj.size() == 0) {
			throw new Exception("调用接口时，mapObj参数不存在，请检查！");
		}
		if (null == dataIds || "".equals(dataIds)) {
			throw new Exception("调用接口时，dataId参数不存在，请检查！");
		}
		String[] datas = dataIds.split(";");
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		PreparedStatement ps = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			CbbTables cbbTables = getCbbTablesById(tableId);
			StringBuffer sbSqlup = new StringBuffer();
			sbSqlup.append("UPDATE " + cbbTables.getTableName() + " SET ");
			Iterator iterator = mapObj.keySet().iterator();
			while (iterator.hasNext()) {
				String colName = String.valueOf(iterator.next());
				String value = String.valueOf(mapObj.get(colName));
				String colType = "";
				colType = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
				if ("string".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + "= NULL,");
					} else {
						sbSqlup.append(colName + "='" + value + "',");
					}
				} else if ("integer".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + " = NULL,");
					} else {
						sbSqlup.append(colName + "=" + value + ",");
					}
				} else if ("date".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + "= NULL,");
					} else {
						sbSqlup.append(colName + "= TO_DATE('" + value + "','yyyy-MM-dd'),");
					}
				} else if ("float".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + "= NULL,");
					} else {
						sbSqlup.append(colName + "=" + value + ",");
					}
				} else if ("blob".equals(colType)) {
					sbSqlup.append(colName + " = NULL,");
				} else if ("clob".equals(colType)) {
					if (value == null || "".equals(value) || "null".equals(value)) {
						sbSqlup.append(colName + " = NULL,");
					} else {
						sbSqlup.append(colName + " ='" + value + "',");
					}
				}
			}
			String upSql = sbSqlup.substring(0, sbSqlup.length() - 1);
			conn.setAutoCommit(false);
			upSql = upSql + " WHERE ID = ?";
			ps = conn.prepareStatement(upSql);

			for (int i = 0; i < datas.length; i++) {
				ps.setString(1, datas[i]);
				ps.addBatch();
				// if (i != 0 && i % 500 == 0) {
				// ps.executeBatch();
				// }
			}
			ps.executeBatch();
			conn.commit();

			// 判断并执行反更新操作(不是组卷操作，文件ID串传空)
			String ajDataId = "";
			if (param.containsKey("ajDataId")) {
				ajDataId = String.valueOf(param.get("ajDataId"));
				Map<String, Object> params = new HashMap<String, Object>();
				params.put("modleName", modleName);
				params.put("markerUpdate", markerUpdate);
				updateAjDataByWjdataByInfs(tableId, ajDataId, orgId, deptId, sysId, nodeId, "", params);
			}
			SysLogUtil.log(modleName, "更新记录", OpType.update, OpResult.success, LogBaseFactory.getLogBase());
		} catch (Exception e) {
			conn.rollback();
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (ps != null) {
				try {
					ps.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					conn.setAutoCommit(true);
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

	/**
	 * 通过记录id删除附件表,关系表,缩略图表对应记录
	 *
	 * @author 钟一华
	 * @param ids
	 *            void
	 * @throws
	 */
	public void deleteAttachmentAndRelationAndMarkerById(String ids) throws Exception {
		String bucketName = avicit.cbb.techclass.dxcc.JProperties.getFileProperties("bucketName"); // 桶名
		String folderName = avicit.cbb.techclass.dxcc.JProperties.getFileProperties("folderName");
		Assert.notNull(ids);
		String mongoId = "LANTOP";
		String[] idsArray = ids.split(";");
		for (int i = 0; i < idsArray.length; i++) {
			String recordId = idsArray[i];
			List<SysFileUpload> listAtt = new ArrayList<SysFileUpload>();
			String hql = "from SysFileUpload where FILE_BUSINESS_ID = ?";
			listAtt = this.hibernateDao.find(hql, recordId);
			for (int j = 0; j < listAtt.size(); j++) {
				SysFileUpload sfu = listAtt.get(j);
				String pkId = sfu.getId();
				String fileuploadBusinessTableName = sfu.getFILE_BUSINESS_TABLE_NAME();
				String fileuploadBusinessId = sfu.getFILE_BUSINESS_ID();
				String fileName = sfu.getFILE_NAME();
				String attachType = sfu.getFILE_TYPE();
				// 数据库
				if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "database".equals(SAVE_TYPE)) {
					sysFileUploadService.deleteFileByCondition(" where ID='" + pkId + "'");
					if (null != fileUploadService.getAfterEvent()) {
						fileUploadService.getAfterEvent().afterDelFileByDB(sfu);
					}
				} else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "disk".equals(SAVE_TYPE)) {// 磁盘
					File folder = FileUtil.getDoccenterDir(doccenterPath, fileuploadBusinessTableName, fileuploadBusinessId);
					if (folder.isDirectory()) {
						File file = new File(folder.getAbsolutePath() + FileUtil.getSep() + fileName);
						if (file.exists()) {
							file.delete();
						}
					}
					sysFileUploadService.deleteFileByCondition(" where ID='" + pkId + "'");
					if (null != fileUploadService.getAfterEvent()) {
						fileUploadService.getAfterEvent().afterDelFileByDisk(sfu);
					}
				} else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "fastdfs".equals(SAVE_TYPE)) {// fastdfs
					try {
						// 从fastdfs删除文件
						FastDfsUtil.deleteFile(sfu.getFastfdsLocation());
						sysFileUploadService.deleteFileByCondition(" where ID='" + pkId + "'");
						if (null != fileUploadService.getAfterEvent()) {
							fileUploadService.getAfterEvent().afterDelFileByFastdfs(sfu);
						}
					} catch (Exception e) {
						e.printStackTrace();
					}

				} else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "mongodb".equals(SAVE_TYPE)) {// mongodb
					sysFileUploadService.deleteFileByCondition(" where ID='" + pkId + "'");
					if (null != fileUploadService.getAfterEvent()) {
						fileUploadService.getAfterEvent().afterDelFileByOther(sfu, mongoId);
					}
				} else if (SAVE_TYPE != null && !"".equals(SAVE_TYPE) && "s3".equals(SAVE_TYPE)){
					getS3Service().delObject(getS3(),bucketName,folderName+"/"+pkId+"."+attachType); // SanXiaFiles delete by zhaoxiaolong 删除对象存储中的文件
				}else {
					sysFileUploadService.deleteFileByCondition(" where ID='" + pkId + "'");
					if (null != fileUploadService.getAfterEvent()) {
						fileUploadService.getAfterEvent().afterDelFileByOther(sfu, mongoId);
					}
				}
			}

			// // 删除附件记录
			// String sql = "DELETE FROM SYS_ATTACHMENT WHERE PARENT_REGISTER_ID = '" + recordId + "'";
			// this.jdbcAvicit.getJdbcTemplate().execute(sql);
			// // 删除全文文件关系
			// String delRelation = "DELETE FROM CBB_DOC_RELATION WHERE RECORD_ID = '" + recordId + "'";
			// this.jdbcAvicit.getJdbcTemplate().execute(delRelation);
			// // 删除文件缩略图
			// String delMarker = "DELETE FROM CBB_SYS_MARKER WHERE RECORD_ID = '" + recordId + "'";
			// this.jdbcAvicit.getJdbcTemplate().execute(delMarker);
		}
	}

	/**
	 * 根据SQL查询所需要的数据（纯动态表,公共字段列带分页，供列表显示）
	 *
	 * @author 朱锋
	 * @param sql
	 * @param pageNo
	 * @param pageSize
	 * @param sysId
	 * @param orgId
	 * @param deptId
	 * @param flag
	 *            是否数据转换（Y：是，N：否）
	 * @param allListColName
	 *            列别名
	 * @param paramMap
	 *            （目前是空，备用参数集合）
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasBySqlByDtByIntfs(String sql, String pageNo, String pageSize, String sysId, List<String> allListColName, String orgId, String deptId, String flag, Map<String, Object> paramMap) throws Exception {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();// 返回值对象
		List<String> colIds = new ArrayList<String>();
		StringBuffer queryLookupSql = new StringBuffer();
		queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
		queryLookupSql.append(" WHERE T.COLUMN_ID IN (");
		List<Map<String, Object>> publicColList = commTableManagerIntfsService.getCbbTableAndColumnsByTabNameByIntfs(orgId, deptId, sysId, "LANTOP_PUB_FIELD"); // 公共字段
		// 获得存在通用代码列的列id
		for (int i = 0; i < publicColList.size(); i++) {
			Map<String, Object> pubMap = publicColList.get(i);
			String pubColDropdownType = String.valueOf(pubMap.get("COL_DROPDOWN_TYPE"));// 选择类型
			String pubColId = String.valueOf(pubMap.get("COL_ID"));// 列ID
			if ("1".equals(pubColDropdownType) || "2".equals(pubColDropdownType)) {
				queryLookupSql.append("'" + pubColId + "',");
				colIds.add(pubColId);
			}
		}
		String querySql = "";
		if (queryLookupSql.toString().endsWith(",")) {
			querySql = queryLookupSql.substring(0, queryLookupSql.length() - 1) + ")";
		}
		// 查询出列中所需通用代码
		List<Map<String, Object>> lookupList = new ArrayList<Map<String, Object>>();
		if (colIds.size() > 0) {
			lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(querySql);
		}
		// 创建通用代码map便于赋值
		Map<String, Map<String, String>> lookupMapKeyValue = new HashMap<String, Map<String, String>>();
		for (int i = 0; i < colIds.size(); i++) {
			Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
			for (int j = 0; j < lookupList.size(); j++) {
				Map<String, Object> lookupMap = lookupList.get(j);
				if (colIds.get(i).equals(lookupMap.get("COLUMN_ID"))) {
					lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
				}
			}
			lookupMapKeyValue.put(colIds.get(i), lookupNameCodeMap);
		}
		// 构造PAGE对象
		String sqlPage = "";
		Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
		page.setPageSize(ComUtil.getPageSize(pageSize));
		page.setPageNo(ComUtil.getPageNo(pageNo));
		Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());
		String sqlCount = "select count(1) from (" + sql + ")";
		long count = 0;
		int firstResult = pageBean.getFirstEntityIndex();
		int maxResults = pageBean.getRows();
		if (firstResult <= 0) {
			sqlPage = "select * from ( " + sql + " ) where rownum <= " + maxResults;
		} else {
			sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + sql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			rs = statement.executeQuery(sqlCount);
			while (rs.next()) {
				count = rs.getLong(1);
			}
			rs = statement.executeQuery(sqlPage);
			int num = 0;
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				if (num == 0) {
					map.put("ROW_COUNT", count);
				}
				num++;
				for (int i = 0; i < allListColName.size(); i++) {
					String allColName = allListColName.get(i);
					String value = rs.getString(allColName);
					if (null != flag && !"Y".equals(flag)) {
						for (int j = 0; j < publicColList.size(); j++) {
							Map<String, Object> pubMap = publicColList.get(j);
							String colName = String.valueOf(pubMap.get("COL_NAME"));// 字段英文名称
							if (allColName.equals(colName)) {
								String colDropdownType = String.valueOf(pubMap.get("COL_DROPDOWN_TYPE"));// 选择类型
								String colId = String.valueOf(pubMap.get("COL_ID"));// 列ID
								// 列类型
								String colType = String.valueOf(pubMap.get("COL_TYPE"));// 字段类型
								// 列规则名称
								String colRuleName = String.valueOf(pubMap.get("COL_RULE_NAME"));// 字段规则名称
								// 列自定义选择框路径
								String customPath = String.valueOf(pubMap.get("CUSTOM_PATH"));// 列自定义选择框路径
								if ("string".equals(colType)) {
									value = rs.getString(allColName);
								} else if ("integer".equals(colType)) {
									value = rs.getString(allColName);
									value = "null".equals(value) ? "" : value;
								} else if ("date".equals(colType)) {
									value = rs.getDate(allColName) + "";
									value = "null".equals(value) ? "" : value;
								} else if ("float".equals(colType)) {
									value = rs.getString(allColName);
									value = "null".equals(value) ? "" : value;
								} else if ("clob".equals(colType)) {
									Clob clobInData = rs.getClob(allColName);
									if (null != clobInData) {
										int clobLength = (int) clobInData.length();
										value = clobInData.getSubString(1, clobLength);
									}
								}
								if ("1".equals(colDropdownType) || "2".equals(colDropdownType)) {
									Map<String, String> showLookupMap = lookupMapKeyValue.get(colId);
									map.put(allColName, showLookupMap.get(value) == null ? value : showLookupMap.get(value));
									map.put(allColName + "_CODE", value);
									// add end by zyh 2015.06.15
								} else if ("user".equals(colRuleName)) {
									if (!"".equals(value) && null != value && !"null".equals(value)) {
										String[] users = value.split(",");
										String usersName = "";
										String userId = "";
										for (int q = 0; q < users.length; q++) {
											if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
												SysUser su = userLoader.getSysUserById(users[q]);
												if (null != su) {
													usersName = usersName + su.getName() + ",";
													userId = userId + users[q] + ",";
												} else {
													usersName = usersName + users[q] + ",";
													userId = userId + users[q] + ",";
												}
											}
										}
										usersName = usersName.substring(0, usersName.length() - 1);
										userId = userId.substring(0, userId.length() - 1);
										map.put(allColName, usersName);
										map.put(allColName + "_CODE", userId);
									}
								} else if ("dept".equals(colRuleName)) {
									if (!"".equals(value) && null != value && !"null".equals(value)) {
										String[] depts = value.split(",");
										String deptName = "";
										String deptIds = "";
										for (int q = 0; q < depts.length; q++) {
											if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
												SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
												if (null != sdt) {
													deptName = deptName + sdt.getDeptName() + ",";
													deptIds = deptIds + depts[q] + ",";
												} else {
													deptName = deptName + depts[q] + ",";
													deptIds = deptIds + depts[q] + ",";
												}
											}
										}
										deptName = deptName.substring(0, deptName.length() - 1);
										deptIds = deptIds.substring(0, deptIds.length() - 1);
										map.put(allColName, deptName);
										map.put(allColName + "_CODE", deptIds);
									}
								} else if ("custom".equals(colRuleName)) {
									if (!"".equals(value) && null != value && !"null".equals(value)) {
										// 截取表名，字段值
										if (!"".equals(customPath) && null != customPath) {
											String[] url = customPath.split("[?]");
											if (url.length > 1) {
												String[] arg = url[1].split("&");// 表名，字段值字符串
												if (arg.length > 1) {
													String cNames = "";// 返回的显示值字符串
													String tName = arg[0].split("=")[1];// 表名
													String cName = arg[1].split("=")[1];// 列名
													StringBuffer sbSqlCustom = new StringBuffer();
													sbSqlCustom.append("SELECT T." + cName + "\n");
													sbSqlCustom.append("  FROM " + tName + " T\n");
													sbSqlCustom.append(" WHERE T.ID IN (");
													String[] datas = value.split(",");
													for (int d = 0; d < datas.length; d++) {
														if (d == datas.length - 1) {
															sbSqlCustom.append("'" + datas[d] + "'\n");
														} else {
															sbSqlCustom.append("'" + datas[d] + "',\n");
														}
													}
													sbSqlCustom.append(")");
													// JDBC实现
													// 查询列的值，并且给attribute02赋值
													Statement statements = null;
													ResultSet rss = null;
													try {
														statements = conn.createStatement();
														rss = statements.executeQuery(sbSqlCustom.toString());
														while (rss.next()) {
															cNames = cNames + rss.getString(cName) + ",";
														}
														if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
															cNames = cNames.substring(0, cNames.length() - 1);
														}
														map.put(allColName, cNames);
													} catch (Exception e) {
														e.printStackTrace();
														throw new Exception("数据库操作异常，请联系管理员！");
													} finally {
														if (rss != null) {
															try {
																rss.close();
																rss = null;
															} catch (Exception e) {
																e.printStackTrace();
															}
														}
														if (statements != null) {
															try {
																statements.close();
																statements = null;
															} catch (Exception e) {
																e.printStackTrace();
															}
														}
													}
												}
											}
										}
									}
								} else {
									map.put(allColName, value);
								}
							}
						}
					} else {
						map.put(allColName, value);
					}
				}
				list.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return list;
	}

	/**
	 * 获取字段下的通用代码集合
	 *
	 * @author 郭亮
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param colId
	 * @return
	 * @throws Exception
	 */
	public Map<String, Map<String, String>> getColLookupCode(String orgId, String deptId, String sysId, String tableId, String colId) throws Exception {
		Map<String, Map<String, String>> mapCode = new HashMap<String, Map<String, String>>();
		CbbTabColumns cbbTabColumns = new CbbTabColumns();
		cbbTabColumns = getCbbTabColumnsById(colId);
		// 判断该字段是否存在通用代码
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("WITH T1 AS\n");
		sbSql.append(" (SELECT CTCC.LOOKUP_NAME, CTCC.LOOKUP_CODE, CTCC.CODE_ORDER\n");
		sbSql.append("    FROM CBB_TAB_COL_CODE CTCC\n");
		sbSql.append("   WHERE CTCC.COLUMN_ID = '" + cbbTabColumns.getId() + "' AND CTCC.CODE_IS_VALID = 'Y'\n");
		sbSql.append("  UNION\n");
		sbSql.append("  SELECT CLV.LOOKUP_NAME, CLV.LOOKUP_CODE, CLV.CODE_ORDER\n");
		sbSql.append("    FROM CBB_TAB_COL_SYS_CODE CTCSC\n");
		sbSql.append("    LEFT JOIN CBB_LOOKUP_V CLV\n");
		sbSql.append("      ON CLV.ID = CTCSC.SYS_LOOKUP_ID\n");
		sbSql.append("   WHERE CTCSC.COLUMN_ID = '" + cbbTabColumns.getId() + "')\n");
		sbSql.append("SELECT T1.LOOKUP_NAME, T1.LOOKUP_CODE FROM T1 ORDER BY T1.CODE_ORDER");
		List<Object[]> colCodeList = hibernateDao.findBySQL(sbSql.toString());
		Map<String, String> map = new LinkedHashMap<String, String>();
		for (int j = 0; j < colCodeList.size(); j++) {
			Object obj[] = colCodeList.get(j);
			String lookupName = String.valueOf(obj[0]);// 显示值
			String lookupCode = String.valueOf(obj[1]);// 真实值
			map.put(lookupCode, lookupName);
		}
		/******
		 * 2015/07/24增加 - 郭亮（字段配置统计生成时根据配置信息计算后的值不在原通用代码中，将字段的值加到通用代码集合中）
		 *******/
		String colValue = cbbTabColumns.getColValue();
		if ("5".equals(cbbTabColumns.getColGeneMethod())) {
			if (!map.containsKey(colValue)) {
				map.put(colValue, colValue);
			}
		}
		/******
		 * 2015/07/24增加 - 郭亮（字段配置统计生成时根据配置信息计算后的值不在原通用代码中，将字段的值加到通用代码集合中）
		 *******/
		mapCode.put(cbbTabColumns.getColName(), map);
		return mapCode;
	}

	/**
	 * 批量修改数据(同字段,多值)
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param mapParam P1
	 *            <key:dataMap,value:Map<String(数据ID),Map<String(字段英文名),Object(
	 *            字段值)>>>
	 *            P2
	 *            <key:modleName,String>
	 * @throws Exception
	 */
	@Override
	public void updateRecordByBatchByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, Map<String, Object> mapParam) throws Exception {
		String modleName = "XXX模块";
		if (mapParam.containsKey("modleName")) {
			modleName = (String) mapParam.get("modleName");
		}
		Map<String, Map<String, Object>> datamaps = new HashMap<String, Map<String, Object>>();
		// 验证参数是否存在
		if (mapParam.containsKey("dataMap")) {
			datamaps = (Map<String, Map<String, Object>>) mapParam.get("dataMap");
		} else {
			throw new Exception("参数dataMap不存在！");
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		PreparedStatement ps = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			conn.setAutoCommit(false);
			CbbTables cbbTables = getCbbTablesById(tableId);
			StringBuffer updateSql = new StringBuffer();
			Map<String, String> colTypeMap = new HashMap<String, String>();// 字段类型集合
			updateSql.append("UPDATE " + cbbTables.getTableName() + " set ");
			Iterator<String> itd = datamaps.keySet().iterator();
			if (itd.hasNext()) {
				String dataId = itd.next();
				Map<String, Object> dataMap = datamaps.get(dataId);
				Iterator<String> itq = dataMap.keySet().iterator();
				while (itq.hasNext()) {
					String colName = itq.next();// 列英文名
					String type = getColTypeByTableIdAndColNameByIntfs(orgId, deptId, sysId, tableId, colName);
					colTypeMap.put(colName, type);
					updateSql.append(colName + " = ?,");
				}
			}
			String modleSql = updateSql.toString().substring(0, updateSql.length() - 1);
			modleSql = modleSql + " where id = ?";
			ps = conn.prepareStatement(modleSql);
			// 开始加数据
			Iterator<String> itb = datamaps.keySet().iterator();
			while (itb.hasNext()) {
				int index = 1;// 批量下标
				String dataId = itb.next();
				Map<String, Object> dataMap = datamaps.get(dataId);
				Iterator<String> itq = dataMap.keySet().iterator();
				while (itq.hasNext()) {
					String colName = itq.next();// 列英文名
					String value = String.valueOf(dataMap.get(colName));// 具体的值
					String colType = colTypeMap.get(colName);
					if ("string".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							ps.setString(index, "");
						} else {
							ps.setString(index, value);
						}
					} else if ("integer".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							ps.setNull(index, Types.INTEGER);
						} else {
							ps.setLong(index, Long.valueOf(value));
						}
					} else if ("date".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							ps.setNull(index, Types.DATE);
						} else {
							ps.setDate(index, Date.valueOf(value));
						}
					} else if ("float".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							ps.setNull(index, Types.FLOAT);
						} else {
							ps.setFloat(index, Float.valueOf(value));
						}
					} else if ("blob".equals(colType)) {
						ps.setNull(index, Types.BLOB);
					} else if ("clob".equals(colType)) {
						if (value == null || "".equals(value) || "null".equals(value)) {
							ps.setNull(index, Types.CLOB);
						} else {
							ps.setString(index, value);
						}
					}
					index++;
				}
				ps.setString(index, dataId);
				ps.addBatch();
			}
			ps.executeBatch();
			conn.commit();
			SysLogUtil.log(modleName, "批量修改记录", OpType.update, OpResult.success, LogBaseFactory.getLogBase());
		} catch (Exception e) {
			conn.rollback();
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (ps != null) {
				try {
					ps.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					conn.setAutoCommit(true);
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

	/**
	 * 根据tableId、nodeId获取tabNodeId（文件类型取‘个人文件’‘部门文件’节点ID作为tabNodeId）
	 * @author 郭亮
	 * @param sysId 必填
	 * @param tableId 必填
	 * @param nodeId
	 * @return
	 * @throws Exception List<Object>
	 */
	@Override
	public String getCbbTabNodeIdByTableId(String sysId, String tableId, String nodeId) throws Exception {
		if (null == sysId || "".equals(sysId) || "null".equals(sysId)) {
			throw new Exception("调用方法时sysId参数不存在，请检查！");
		}
		if (null == tableId || "".equals(tableId) || "null".equals(tableId)) {
			throw new Exception("调用方法时tableId参数不存在，请检查！");
		}
		sysId = sysId.toUpperCase(); // 将参数转换为大写
		String tabNodeId = "";
		try {
			// 1、调用rest服务获取文件类型tabNodeId
//			CbbArchiveClassRestClient lantopArchiveClassRestClient = new CbbArchiveClassRestClient("/api/im/lantop/basic/archiveclass");
//			ResponseMsg<String> responseMsg = RestClient.doPost(lantopArchiveClassRestClient.getRestUrl("/getFileTabNodeIdByNodeId/v1"), nodeId, new GenericType<ResponseMsg<String>>() {
//			});
			ResponseMsg<String> responseMsg = RestClient.doPost("/getFileTabNodeIdByNodeId/v1", nodeId, new GenericType<ResponseMsg<String>>() {
			});
			if (responseMsg.getRetCode().equals(ResponseStatus.HTTP_OK)) {
				tabNodeId = responseMsg.getResponseBody();
				if (null == tabNodeId || "".equals(tabNodeId) || "null".equals(tabNodeId)) {
					// 2、如果文件类型获取到的tabNodeId为空，则用档案类型的方式处理
					StringBuffer sbSql = new StringBuffer();
					sbSql.append("SELECT T.ID\n");
					sbSql.append(" FROM CBB_TAB_NODE T\n");
					sbSql.append(" WHERE T.TABLE_ID = '" + tableId + "'\n");
					sbSql.append(" AND T.SYS_ID = '" + sysId + "'\n");
					if (null != nodeId && !"".equals(nodeId) && !"null".equals(nodeId)) {
						sbSql.append(" AND T.NODE_ID = '" + nodeId + "'");
					}
					List<String> list = hibernateDao.findBySQL(sbSql.toString());
					if (list.size() > 0) {
						tabNodeId = list.get(0);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tabNodeId;
	}

	/**
	 * 根据tableId、nodeId获取modelNodeId（模板文件夹NODE_ID）
	 * @param sysId
	 * @param tableId
	 * @param nodeId
	 * @return
	 * @throws Exception
	 * @throws
	 */
	@Override
	public String getCbbTabModelNodeIdByNodeId(String nodeId) throws Exception {
		String modelNodeId = "";
		try {
			// 1、调用rest服务获取文件类型tabNodeId
//			CbbArchiveClassRestClient lantopArchiveClassRestClient = new CbbArchiveClassRestClient("/api/im/lantop/basic/archiveclass");
//			ResponseMsg<String> responseMsg = RestClient.doPost(lantopArchiveClassRestClient.getRestUrl("/getFileModelNodeIdByNodeId/v1"), nodeId, new GenericType<ResponseMsg<String>>() {
//			});
			ResponseMsg<String> responseMsg = RestClient.doPost("/getFileModelNodeIdByNodeId/v1", nodeId, new GenericType<ResponseMsg<String>>() {
			});
			if (responseMsg.getRetCode().equals(ResponseStatus.HTTP_OK)) {
				modelNodeId = responseMsg.getResponseBody();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return modelNodeId;
	}

	/**
	 * 根据tabNodeId获取节点著录定义配置信息
	 * @author 郭亮
	 * @param tabNodeId 表与节点关系ID，必填
	 * @return
	 * @throws Exception List<Map<String,Object>>
	 */
	public List<Map<String, Object>> getTabNodeRecordInfoByTabNodeId(String tabNodeId) throws Exception {
		if (null == tabNodeId || "".equals(tabNodeId) || "null".equals(tabNodeId)) {
			throw new Exception("调用方法时tabNodeId参数不存在，请检查！");
		}
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		String sql = "SELECT T.* FROM CBB_TAB_NODE_RECORD T WHERE T.TAB_NODE_ID = '" + tabNodeId + "'";
		list = jdbcAvicit.queryForMap(sql, null);
		return list;
	}

	/**
	 *
	 * @param
	 * @return Byte
	 * @throws
	 */
	public byte[] toByteArray(InputStream input) throws IOException {
		byte[] b = null;
		ByteArrayOutputStream output = null;

		try {
			output = new ByteArrayOutputStream();
			byte[] buffer = new byte[4096];
			int n = 0;
			while (-1 != (n = input.read(buffer))) {
				output.write(buffer, 0, n);
			}

			b = output.toByteArray();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			output.close();
		}

		return b;
	}

	/**
	 * 借助字节输出流ByteArrayOutputStream来实现字节数组的合并
	 * */
	public byte[] streamCopy(List<byte[]> srcArrays) {
		byte[] destAray = null;
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		try {
			for (byte[] srcArray : srcArrays) {
				bos.write(srcArray);
			}
			bos.flush();
			destAray = bos.toByteArray();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				bos.close();
			} catch (IOException e) {
			}
		}
		return destAray;
	}

	/**
	 * 根据SQL单字段分组查询数据，（可分页）
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param sql
	 * @param pageNo
	 * @param pageSize
	 * @param mapParam
	 * @return
	 * @throws Exception List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getDataBysSqlByIntfs(String orgId, String deptId, String sysId, String tableId, String tableName, String colId, String colName1, String sql, String pageNo, String pageSize, Map<String, Object> mapParam) throws Exception {
		List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();// 返回的结果集
		if (null != sql && !"".equals(sql) && !"null".equals(sql)) {
			// 构造PAGE对象
			String sqlPage = "";// 最终执行SQL语句
			long count = 0;// 最大条目数
			String sqlCount = "";
			if (!"".equals(pageNo) && !"".equals(pageSize)) {
				sqlCount = "SELECT COUNT(1) AS COUNT FROM (" + sql + ")";
				List<Map<String, Object>> listCount = jdbcAvicit.queryForMap(sqlCount, null);
				count = Integer.parseInt(String.valueOf(listCount.get(0).get("COUNT")));
				Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
				page.setPageSize(ComUtil.getPageSize(pageSize));
				page.setPageNo(ComUtil.getPageNo(pageNo));
				Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());

				int firstResult = pageBean.getFirstEntityIndex();
				int maxResults = pageBean.getRows();
				if (firstResult <= 0) {
					sqlPage = "select * from ( " + sql + " ) where rownum <= " + maxResults;
				} else {
					sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + sql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
				}
			} else {
				sqlPage = sql;
			}
			// 连接池
			DBConnectionCustomManager connectionMan = null;
			String poolName = orgId + "_" + sysId;
			Connection conn = null;
			Statement statement = null;
			ResultSet rs = null;
			try {
				// 实例化连接池
				connectionMan = DBConnectionCustomManager.getInstance(poolName);
				// 获取连接
				conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
				statement = conn.createStatement();
				if (!"".equals(sqlCount)) {
					rs = statement.executeQuery(sqlCount);
					while (rs.next()) {
						count = rs.getLong(1);
					}
				}
				rs = statement.executeQuery(sqlPage);
				ResultSetMetaData m = rs.getMetaData();// 获取列表的表头
				int columns = m.getColumnCount();
				int num = 0;
				while (rs.next()) {
					Map<String, Object> map = new HashMap<String, Object>();
					if (!"".equals(sqlCount) && num == 0) {
						map.put("ROW_COUNT", count);
						num++;
					}
					for (int i = 1; i <= columns; i++) {
						String colName = m.getColumnName(i);
						String value = rs.getString(colName);
						if ((colName1 + "_GROUP_DATE").equals(colName)) {
							colName = colName1;
						}
						if (null == value || "".equals(value) || "null".equals(value)) {
							value = "其他";
						} else {
							// 通过字段配置，转换真实值
							List<Map<String, Object>> colList = commTableManagerIntfsService.getCbbColumnsByTableIdAndColNameByIntfs(tableId, colName);
							if (null != colList && colList.size() > 0) {
								String cid = String.valueOf(colList.get(0).get("ID"));
								CbbTabColumns cbbTabColumns = getCbbTabColumnsById(cid);
								String colDropdownType = cbbTabColumns.getColDropdownType();
								String colRuleName = cbbTabColumns.getColRuleName();
								//String colGeneMethod = cbbTabColumns.getColGeneMethod();
								//String colGeneMethodRule = cbbTabColumns.getColGeneMethodRule();
								//String colType = cbbTabColumns.getColType();
								String customPath = cbbTabColumns.getCustomPath();// 自定义URL
								if ("1".equals(colDropdownType) || "2".equals(colDropdownType)) {
									// 该字段为通用代码
									StringBuffer queryLookupSql = new StringBuffer();
									queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
									queryLookupSql.append(" WHERE T.COLUMN_ID = '" + cid + "'");
									// 查询出列中所需通用代码
									List<Map<String, Object>> lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(queryLookupSql.toString());
									// 创建通用代码map便于赋值
									Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
									for (int j = 0; j < lookupList.size(); j++) {
										Map<String, Object> lookupMap = lookupList.get(j);
										if (cid.equals(lookupMap.get("COLUMN_ID"))) {
											lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
										}
									}
									value = lookupNameCodeMap.get(value) == null ? value : lookupNameCodeMap.get(value);
								} else if ("user".equals(colRuleName)) {
									String[] users = value.split(",");
									String usersName = "";
									String userId = "";
									for (int q = 0; q < users.length; q++) {
										if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
											SysUser su = userLoader.getSysUserById(users[q]);
											if (null != su) {
												usersName = usersName + su.getName() + ",";
												userId = userId + users[q] + ",";
											} else {
												usersName = usersName + users[q] + ",";
												userId = userId + users[q] + ",";
											}
										}
									}
									usersName = usersName.substring(0, usersName.length() - 1);
									userId = userId.substring(0, userId.length() - 1);
									value = usersName;
								} else if ("dept".equals(colRuleName)) {
									String[] depts = value.split(",");
									String deptName = "";
									String deptIds = "";
									for (int q = 0; q < depts.length; q++) {
										if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
											SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
											if (null != sdt) {
												deptName = deptName + sdt.getDeptName() + ",";
												deptIds = deptIds + depts[q] + ",";
											} else {
												deptName = deptName + depts[q] + ",";
												deptIds = deptIds + depts[q] + ",";
											}
										}
									}
									deptName = deptName.substring(0, deptName.length() - 1);
									deptIds = deptIds.substring(0, deptIds.length() - 1);
									value = deptName;
								} else if ("custom".equals(colRuleName)) {
									// 截取表名，字段值
									if (!"".equals(customPath) && null != customPath) {
										String[] url = customPath.split("[?]");
										if (url.length > 1) {
											String[] arg = url[1].split("&");// 表名，字段值字符串
											if (arg.length > 1) {
												String cNames = "";// 返回的显示值字符串
												String tName = arg[0].split("=")[1];// 表名
												String cName = arg[1].split("=")[1];// 列名
												StringBuffer sbSqlCustom = new StringBuffer();
												sbSqlCustom.append("SELECT T." + cName + "\n");
												sbSqlCustom.append("  FROM " + tName + " T\n");
												sbSqlCustom.append(" WHERE T.ID IN (");
												String[] datas = value.split(",");
												for (int d = 0; d < datas.length; d++) {
													if (d == datas.length - 1) {
														sbSqlCustom.append("'" + datas[d] + "'\n");
													} else {
														sbSqlCustom.append("'" + datas[d] + "',\n");
													}
												}
												sbSqlCustom.append(")");
												// JDBC实现
												// 查询列的值，并且给attribute02赋值
												Statement statements = null;
												ResultSet rss = null;
												try {
													statements = conn.createStatement();
													rss = statements.executeQuery(sbSqlCustom.toString());
													while (rss.next()) {
														cNames = cNames + rss.getString(cName) + ",";
													}
													if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
														cNames = cNames.substring(0, cNames.length() - 1);
													}
													value = cNames;
												} catch (Exception e) {
													e.printStackTrace();
													throw new Exception("数据库操作异常，请联系管理员！");
												} finally {
													if (rss != null) {
														try {
															rss.close();
															rss = null;
														} catch (Exception e) {
															e.printStackTrace();
														}
													}
													if (statements != null) {
														try {
															statements.close();
															statements = null;
														} catch (Exception e) {
															e.printStackTrace();
														}
													}
												}
											}
										}
									}
								}
							}
						}
						map.put(colName, value);
					}
					listMap.add(map);
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new Exception("数据库操作异常，请联系管理员！");
			} finally {
				if (rs != null) {
					try {
						rs.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (statement != null) {
					try {
						statement.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (conn != null) {
					try {
						connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
		return listMap;
	}

	/**
	 * 处理卷内序号方法
	 * @param param
	 * 			key: orgId, deptId, sysId
	 * 				type:insert/delete   插入/(删除/撤件)
	 * 				parentId: 父数据id
	 * 				tableId: 文件级表id
	 * 				modleName: 获取的模块名
	 * 				ids:删除/撤件的数据ids
	 * @throws Exception void
	 */
	@Override
	public void saveOtherArchiveInNumByIntfsByParam(Map<String, Object> param) throws Exception {
		String orgId = (String) param.get("orgId");
		String deptId = (String) param.get("deptId");
		String sysId = (String) param.get("sysId");
		String type = (String) param.get("type");
		String parentId = (String) param.get("parentId");
		String tableId = (String) param.get("tableId");
		String modleName = (String) param.get("modleName");
		String ids = (String) param.get("ids");
		CbbTables cbbTables = this.getCbbTablesById(tableId);
		if ("insert".equals(type)) {// 插入
			String insertObjNum = (String) param.get("insertObjNum");
			// 更新被插入序列之后的序列自增1
			StringBuffer updateSql = new StringBuffer();
			updateSql.append("UPDATE ");
			updateSql.append(cbbTables.getTableName());
			updateSql.append(" SET ARCHIVE_IN_NUM = ARCHIVE_IN_NUM + 1 WHERE ARCHIVE_IN_NUM >= ");
			updateSql.append(insertObjNum);
			updateSql.append(" AND PARENT_ID = '" + parentId + "'");
			Map<String, Object> modelMap = new HashMap<String, Object>();
			modelMap.put("modleName", modleName);
			this.updateRecordBySqlByIntfs(orgId, deptId, sysId, updateSql.toString(), modelMap);
		} else if ("delete".equals(type)) {// 撤件/删除
			String serachCondition = " AND PARENT_ID = '" + parentId + "' AND (ARCHIVE_STATUS <> '2' OR ARCHIVE_STATUS IS NULL) AND ID NOT IN ('" + ids + "')";
			LinkedHashMap<String, String> searchOrderMap = new LinkedHashMap<String, String>();
			searchOrderMap.put("ARCHIVE_IN_NUM", "ASC");
			Map<String, Object> parameter = new HashMap<String, Object>();
			parameter.put("searchOrder", searchOrderMap);
			// 获取当前案卷下的所有文件信息
			List<Map<String, Object>> list = this.getTableFieldsAndDatasBySearchByOrderbyByIntfs(orgId, deptId, sysId, tableId, "", "", serachCondition, parameter);
			// 连接池
			DBConnectionCustomManager connectionMan = null;
			String poolName = orgId + "_" + sysId;
			Connection conn = null;
			PreparedStatement ps = null;
			try {
				// 实例化连接池
				connectionMan = DBConnectionCustomManager.getInstance(poolName);
				// 获取连接
				conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
				conn.setAutoCommit(false);
				StringBuffer deleteSql = new StringBuffer();
				deleteSql.append("UPDATE " + cbbTables.getTableName() + " SET ARCHIVE_IN_NUM = ? WHERE ID = ?");
				ps = conn.prepareStatement(deleteSql.toString());
				// 批量更新卷内序号
				for (int i = 0; i < list.size(); i++) {
					Map<String, Object> map = list.get(i);
					ps.setInt(1, i + 1);
					ps.setString(2, map.get("ID").toString());
					ps.addBatch();
				}
				ps.executeBatch();
				conn.commit();
			} catch (Exception e) {
				conn.rollback();
				e.printStackTrace();
				throw new Exception("数据库操作异常，请联系管理员！");
			} finally {
				if (ps != null) {
					try {
						ps.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (conn != null) {
					try {
						conn.setAutoCommit(true);
						connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
	}

	/**
	 * 删除数据方法(真删)
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param param
	 * 			key: condition : 需要删除的条件语句
	 * 			key: level : 执行删除的层级 1 文件 2 案卷/盒
	 * @throws Exception void
	 * @throws
	 */
	@Override
	public void deleteDatasByParamByIntfs(String orgId, String deptId, String sysId, String nodeId, Map<String, Object> param) throws Exception {
		// 层级
		String level = (String) param.get("level");
		// 条件
		String condition = (String) param.get("condition");
		List<Map<String, Object>> treeNodeIdList = this.commTableManagerIntfsService.getCbbTableInfoByNodeIdByIntfs(orgId, deptId, sysId, nodeId, "");
		Map<String, Object> modelParam = new HashMap<String, Object>();
		modelParam.put("treeNodeList", treeNodeIdList);
		Map<String, Object> modelDataMap = this.archiveClassManagerIntfsService.getDataNodeInfoByParam(modelParam);
		int dataCount = Integer.parseInt(modelDataMap.get("dataCount").toString());
		String tableId = "";
		String childTableId = "";
		Map<String, Object> listParam = new HashMap<String, Object>();
		if ("1".equals(level)) {// 一级表结构删除
			if (null != treeNodeIdList && (treeNodeIdList.size() == 1 || dataCount == 1)) {
				tableId = (String) treeNodeIdList.get(0).get("ID");
			} else {
				tableId = (String) treeNodeIdList.get(1).get("ID");
			}
			List<Map<String, Object>> dataList = this.getTableFieldsAndDatasBySearchByOrderbyByIntfs(orgId, deptId, sysId, tableId, "", "", condition, listParam);
			List<String> idList = new ArrayList<String>();
			for (int i = 0; i < dataList.size(); i++) {
				Map<String, Object> map = dataList.get(i);
				idList.add((String) map.get("ID"));
				if (i != 0 && i % 500 == 0) {
					this.deleteRecordByDataIdListByIntfs(orgId, deptId, sysId, nodeId, tableId, idList, listParam);
					idList.clear();
				}
			}
			if (idList.size() > 0) {
				this.deleteRecordByDataIdListByIntfs(orgId, deptId, sysId, nodeId, tableId, idList, listParam);
			}
		} else {// 两级表结构删除
			tableId = (String) treeNodeIdList.get(0).get("ID");
			childTableId = (String) treeNodeIdList.get(1).get("ID");
			List<Map<String, Object>> dataList = this.getTableFieldsAndDatasBySearchByOrderbyByIntfs(orgId, deptId, sysId, tableId, "", "", condition, listParam);
			List<String> idList = new ArrayList<String>();
			// 主表删除
			for (int i = 0; i < dataList.size(); i++) {
				Map<String, Object> map = dataList.get(i);
				idList.add((String) map.get("ID"));
				String searchSql = " AND PARENT_ID = '" + map.get("ID") + "'";
				List<Map<String, Object>> childList = this.getTableFieldsAndDatasBySearchByOrderbyByIntfs(orgId, deptId, sysId, childTableId, "", "", searchSql, listParam);
				List<String> childIdList = new ArrayList<String>();
				// 子表删除
				for (int j = 0; j < childList.size(); j++) {
					Map<String, Object> childMap = childList.get(j);
					childIdList.add((String) childMap.get("ID"));
					if (i != 0 && i % 500 == 0) {
						this.deleteRecordByDataIdListByIntfs(orgId, deptId, sysId, nodeId, childTableId, childIdList, listParam);
						childIdList.clear();
					}
				}
				if (childIdList.size() > 0) {
					this.deleteRecordByDataIdListByIntfs(orgId, deptId, sysId, nodeId, childTableId, childIdList, listParam);
				}
				if (i != 0 && i % 500 == 0) {
					this.deleteRecordByDataIdListByIntfs(orgId, deptId, sysId, nodeId, tableId, idList, listParam);
					idList.clear();
				}
			}
			if (idList.size() > 0) {
				this.deleteRecordByDataIdListByIntfs(orgId, deptId, sysId, nodeId, tableId, idList, listParam);
			}
		}
	}

	/**
	 * 根据记录IDS批量删除记录信息
	 *
	 * @author 朱锋
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param tableId
	 * @param dataIds
	 * @throws Exception
	 *             void
	 * @throws
	 */
	public void deleteRecordByDataIdListByIntfs(String orgId, String deptId, String sysId, String nodeId, String tableId, List<String> dataIdList, Map<String, Object> param) throws Exception {
		// -----jdbc批量删除---zyh
		if (dataIdList.size() > 0) {
			CbbTables cbbTables = this.getCbbTablesById(tableId);
			// 连接池
			DBConnectionCustomManager connectionMan = null;
			String poolName = orgId + "_" + sysId;
			Connection conn = null;
			PreparedStatement ps = null;
			try {
				// 实例化连接池
				connectionMan = DBConnectionCustomManager.getInstance(poolName);
				// 获取连接
				conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
				conn.setAutoCommit(false);
				StringBuffer deleteSql = new StringBuffer();
				deleteSql.append("DELETE FROM " + cbbTables.getTableName() + " WHERE ID = ?");
				ps = conn.prepareStatement(deleteSql.toString());
				String dataIds = "";
				for (int i = 0; i < dataIdList.size(); i++) {
					ps.setString(1, dataIdList.get(i));
					ps.addBatch();
					dataIds += dataIdList.get(i);
					if (i != dataIdList.size() - 1) {
						dataIds += ";";
					}
				}
				ps.executeBatch();
				conn.commit();
				// 原纪录日志的,现在都放在业务模块纪录日志
				// 删除附件信息,关系表信息,缩略图信息
				this.deleteAttachmentAndRelationAndMarkerById(dataIds);
			} catch (Exception e) {
				conn.rollback();
				e.printStackTrace();
				throw new Exception("数据库操作异常，请联系管理员！");
			} finally {
				if (ps != null) {
					try {
						ps.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (conn != null) {
					try {
						conn.setAutoCommit(true);
						connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
	}

	/**
	 * @funcion 对文件全文生成MD5摘要
	 * @param file:要加密的文件
	 * @return MD5摘要码
	 */
	public static String getMD5(File file) {
		FileInputStream fis = null;
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			fis = new FileInputStream(file);
			byte[] buffer = new byte[2048];
			int length = -1;
			while ((length = fis.read(buffer)) != -1) {
				md.update(buffer, 0, length);
			}
			byte[] b = md.digest();
			return byteToHexString(b);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			try {
				fis.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * @function 把byte[]数组转换成十六进制字符串表示形式
	 * @param tmp  要转换的byte[]
	 * @return 十六进制字符串表示形式
	 */
	private static String byteToHexString(byte[] tmp) {
		String s;
		// 用字节表示就是 16 个字节
		// 每个字节用 16 进制表示的话，使用两个字符，所以表示成 16 进制需要 32 个字符
		// 比如一个字节为01011011，用十六进制字符来表示就是“5b”
		char str[] = new char[16 * 2];
		int k = 0; // 表示转换结果中对应的字符位置
		for (int i = 0; i < 16; i++) { // 从第一个字节开始，对 MD5 的每一个字节转换成 16 进制字符的转换
			byte byte0 = tmp[i]; // 取第 i 个字节
			str[k++] = hexdigits[byte0 >>> 4 & 0xf]; // 取字节中高 4 位的数字转换, >>> 为逻辑右移，将符号位一起右移
			str[k++] = hexdigits[byte0 & 0xf]; // 取字节中低 4 位的数字转换
		}
		s = new String(str); // 换后的结果转换为字符串
		return s;
	}

	/**
	 * 根据创建时间更新卷内序号方法
	 * @param param
	 * @throws Exception void
	 * @throws
	 */
	@Override
	public void updateArchiveInNumByParam(Map<String, Object> param) throws Exception {
		String tableId = (String) param.get("TABLE_ID");
		String parentId = (String) param.get("PARENT_ID");
		List<Map<String, Object>> list = this.commTableManagerIntfsService.getCbbTableAndColumnsByTabIdByIntfs(tableId);
		if (list.size() > 0) {
			Map<String, Object> map = list.get(0);
			String tableName = (String) map.get("TABLE_NAME");
			StringBuffer sbSql = new StringBuffer();
			sbSql.append("UPDATE " + tableName + " A\n");
			sbSql.append("   SET (A.ARCHIVE_IN_NUM) =\n");
			sbSql.append("       (SELECT RN\n");
			sbSql.append("          FROM (SELECT PARENT_ID,\n");
			sbSql.append("                       CREATION_DATE,\n");
			sbSql.append("                       ID,\n");
			sbSql.append("                       ROW_NUMBER() OVER(ORDER BY CREATION_DATE ASC) RN\n");
			sbSql.append("                  FROM " + tableName + "\n");
			sbSql.append("                 WHERE PARENT_ID = '" + parentId + "') B\n");
			sbSql.append("         WHERE A.ID = B.ID)\n");
			sbSql.append(" WHERE A.PARENT_ID = '" + parentId + "'");
			this.jdbcAvicit.getJdbcTemplate().execute(sbSql.toString());
		}
	}

	/**
	 * 根据tableId和数据id获取页数和下标
	 * @return
	 * @throws Exception String
	 * @throws
	 */
	@Override
	public List<String> getDatasPageNumAndIndexByTableIdRecordId(Map<String, Object> param, String sqlWhere) throws Exception {
		String tableId = (String) param.get("TABLE_ID");
		String pageSize = (String) param.get("PAGE_SIZE");
		String recordId = (String) param.get("SELECT_RECORD_ID");
		String orgId = (String) param.get("ORG_ID");
		String deptId = (String) param.get("DEPT_ID");
		String sysId = (String) param.get("SYS_ID");
		List<Map<String, Object>> list = this.commTableManagerIntfsService.getCbbTableAndColumnsByTabIdByIntfs(tableId);
		List<String> result = new ArrayList<String>();
		if (list.size() > 0) {
			Map<String, Object> map = list.get(0);
			String tableName = (String) map.get("TABLE_NAME");
			// 默认取库结构配置排序
			String sql = "";
			List<Map<String, Object>> sortlist = commTableManagerIntfsService.getColDataOrderByTableId(tableId, sysId, orgId, deptId);
			for (int i = 0; i < sortlist.size(); i++) {
				if (i == 0) {
					sql = sql + " ORDER BY ";
				}
				Map<String, Object> sortMap = sortlist.get(i);
				String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
				String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
				// A-升序，D-降序
				if ("A".equals(sortCode)) {
					sortCode = " ASC";
				} else {
					sortCode = " DESC";
				}
				sql += colName + sortCode;
				if (i != sortlist.size() - 1) {
					sql += ",";
				}
			}

			StringBuffer sbSql = new StringBuffer();
			sbSql.append("WITH T1 AS\n");
			sbSql.append(" (SELECT ROWNUM N, Z.ID\n");
			sbSql.append("    FROM (SELECT T.ID\n");
			sbSql.append("            FROM " + tableName + " T\n");
			sbSql.append("           WHERE 1 = 1\n");
			sbSql.append("             " + sqlWhere + sql + ") Z)\n");
			sbSql.append("SELECT TO_CHAR(T1.N / " + pageSize + ") AS MSG, TO_CHAR(MOD(T1.N, 20)) AS QY, T1.*\n");
			sbSql.append("  FROM T1\n");
			sbSql.append(" WHERE T1.ID = '" + recordId + "'");

			List<Map<String, Object>> resultList = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
			if (resultList.size() > 0) {
				Map<String, Object> resultMap = resultList.get(0);
				// 求商
				String msg = (String) resultMap.get("MSG");
				// 求余
				String qy = (String) resultMap.get("QY");
				String[] msgs = msg.split("\\.");
				if (null == msgs[0] || "".equals(msgs[0])) {
					msgs[0] = "0";
				}
				int pn = 0;
				if (msgs.length == 2) { // 存在小数时进
					if ("0".equals(qy)) {
						pn = Integer.parseInt(msgs[0]);
					} else {
						pn = Integer.parseInt(msgs[0]) + 1;
					}
					float index = Float.parseFloat("0." + msgs[1]) * Integer.parseInt(pageSize);
					result.add(pn + "");
					result.add(index + ""); // 默认第0个下标
				} else { // 被整除时进
					if ("0".equals(qy)) {
						pn = Integer.parseInt(msgs[0]);
					} else {
						pn = Integer.parseInt(msgs[0]) + 1;
					}
					result.add(pn + "");
					result.add(pageSize); // 默认第0个下标
				}
			} else {
				result.add("1"); // 默认第1页
				result.add("0"); // 默认第0个下标
			}
		} else {
			result.add("1"); // 默认第1页
			result.add("0"); // 默认第0个下标
		}
		return result;
	}

	/**
	 * 获取查询条件拼接中文查询语句
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param userId
	 * @param orgCode
	 * @param nodeId
	 * @param tableId
	 * @param json
	 * @param sessionLanguageCode
	 * @return
	 * @throws Exception String
	 */
	@Override
	public String getSearchString(String orgId, String deptId, String sysId, String userId, String orgCode, String nodeId, String tableId, String json, String sessionLanguageCode) throws Exception {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("currentUserId", userId);
		param.put("currentDeptId", deptId);
		param.put("currentOrgCode", orgCode);
		param.put("languageCode", sessionLanguageCode);
		param.put("nodeId", nodeId);
		List<Map<String, Object>> searchColList = this.getFieldsByConditionByIntfs(orgId, deptId, sysId, tableId, "4", "", param); // 查询区域
		Map<String, Object> searchMap = new HashMap<String, Object>();
		if (json != null && !"".equals(json)) {
			searchMap = JsonUtils.newInstance().Json2Bean2Form(json, Map.class);
		}
		searchMap.remove("checkNodes");
		searchMap.remove("resultSearch");
		Map<String, String> searchParam = new HashMap<String, String>();
		Iterator<String> searchList = searchMap.keySet().iterator();
		while (searchList.hasNext()) {
			String searchName = searchList.next();
			String searchValue = (String) searchMap.get(searchName);
			String searchType = searchName.substring(0, 4);
			if ("SELE".equals(searchType)) {
				if (null != searchValue && !"".equals(searchValue)) {
					searchParam.put(searchName.substring(5), searchValue);
				}
			} else if ("USER".equals(searchType) || "DEPT".equals(searchType)) {
				int index = searchName.lastIndexOf("_");
				if (null != searchValue && !"".equals(searchValue)) {
					searchParam.put(searchName.substring(5, index), searchValue);
				}
			} else if ("INPU".equals(searchType)) {
				if (null != searchValue && !"".equals(searchValue)) {
					searchParam.put(searchName.substring(5), searchValue);
				}
			} else if ("DATE".equals(searchType)) {
				if (null != searchValue && !"".equals(searchValue)) {
					searchParam.put(searchName.substring(5), searchValue);
				}
			} else {
				if (null != searchValue && !"".equals(searchValue)) {
					searchParam.put(searchName.substring(5), searchValue);
				}
			}
		}
		String searchString = "";
		for (int i = 0; i < searchColList.size(); i++) {
			Map<String, Object> searchColMap = searchColList.get(i);
			String colName = (String) searchColMap.get("COL_NAME");
			String colLabel = (String) searchColMap.get("COL_LABEL");
			String value = searchParam.get(colName);
			if (null != value && !"".equals(value)) {
				searchString += colLabel + " 包含 " + value + " 并且 ";
			}
		}
		if (!"".equals(searchString)) {
			searchString = searchString.substring(0, searchString.length() - 3);
		}
		return searchString;
	}

	/**
	 * 根据map中的某个key 去除List中重复的map
	 * @author  shijing
	 * @param list
	 * @param mapKey
	 * @return
	 */
	public List<Map<String, Object>> removeRepeatMapByKey(List<Map<String, Object>> list, String mapKey) {
		// 把list中的数据转换成msp,去掉同一id值多余数据，保留查找到第一个id值对应的数据
		List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
		Map<String, Map> msp = new HashMap<String, Map>();
		for (int i = list.size() - 1; i >= 0; i--) {
			Map map = list.get(i);
			String id = (String) map.get(mapKey);
			map.remove(mapKey);
			msp.put(id, map);
		}
		// 把msp再转换成list,就会得到根据某一字段去掉重复的数据的List<Map>
		Set<String> mspKey = msp.keySet();
		for (String key : mspKey) {
			Map newMap = msp.get(key);
			newMap.put(mapKey, key);
			listMap.add(newMap);
		}
		return listMap;
	}

	/**
	 * 根据表ID及数据ID集合获得数据对应的密级
	 *
	 * @author 张余
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param ids
	 * @return
	 * @throws Exception
	 *             Map<String,Object>
	 * @throws
	 */
	@Override
	public Map<String, Object> getSecretLevelByIdsAndTableId(String orgId, String deptId, String sysId, String tableId, String ids) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		CbbTables cbbTables = getCbbTablesById(tableId);
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT ID,SECRET_LEVEL ");
		sql.append(" FROM " + cbbTables.getTableName());
		sql.append(" WHERE 1=1 ");
		if (ids != null && !ids.equals("")) {
			String[] idst = ids.split(",");
			StringBuffer idSQL = new StringBuffer();
			for (String id : idst) {
				idSQL.append(",'" + id + "'");
			}
			if (!idSQL.equals("")) {
				sql.append(" AND ID IN(" + idSQL.substring(1) + ")");
			}
		}
		List<Map<String, Object>> list = this.jdbcAvicit.getJdbcTemplate().queryForList(sql.toString());
		for (Map<String, Object> m : list) {
			String id = (String) m.get("ID");
			Object secretLevel = m.get("SECRET_LEVEL");
			map.put(id, secretLevel);
		}
		return map;
	}

	/**
	 * 断号查询
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param param key: NODE_ID(必填), TABLE_ID(必填), PARENT_ID(非必填) ...
	 * @return
	 * @throws Exception Map<String,Object>
	 * @throws
	 */
	@Override
	public Map<String, Object> getDisconnectNumByParamByIntfs(String orgId, String deptId, String sysId, Map<String, Object> param) throws Exception {
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("flag", 1);
		/*String nodeId = "";
		if (param.containsKey("NODE_ID")) {
			nodeId = (String) param.get("NODE_ID");
		}*/
		String tableId = "";
		if (param.containsKey("TABLE_ID")) {
			tableId = (String) param.get("TABLE_ID");
		}
		String parentId = "";
		if (param.containsKey("PARENT_ID")) {
			parentId = (String) param.get("PARENT_ID");
		}
		String openParam = "";
		if (param.containsKey("openParam")) {
			openParam = param.get("openParam")==null?"":param.get("openParam").toString();
		}


		/* 向明伟 6月24*/
		List<Map<String, Object>> maps = jdbcAvicit.getJdbcTemplate().queryForList("SELECT TABLE_NAME FROM cbb_tables WHERE ID='" + tableId + "'");
		String tableName = maps.get(0).get("TABLE_NAME") == null ? "" : maps.get(0).get("TABLE_NAME").toString();

		StringBuffer sbSql = new StringBuffer();
		if ("dazl".equals(openParam)){
			sbSql.append(" AND  ARCHIVE_STATUS = '1' ");
//			sbSql.append(" AND ( ARCHIVE_FLOW_STATUS = '1' OR ARCHIVE_FLOW_STATUS = '' OR ARCHIVE_FLOW_STATUS IS NULL )");
		}else if("dabg".equals(openParam)){
			sbSql.append(" AND  ARCHIVE_STATUS IN ('3','4') ");
		}else {
			sbSql.append(" AND ( ARCHIVE_STATUS = '0' OR ARCHIVE_STATUS IS NULL OR ARCHIVE_STATUS = '' )");
			sbSql.append(" AND ( ARCHIVE_FLOW_STATUS = '1' OR ARCHIVE_FLOW_STATUS = '' OR ARCHIVE_FLOW_STATUS IS NULL )");
			sbSql.append(" AND ARCHIVE_SHARE_STATUS = '2'");
		}

		List<Map<String, Object>> maps1 = jdbcAvicit.getJdbcTemplate().queryForList("\n" +
				"SELECT wmsys.wm_concat (T1.ARCHIVE_IN_NUM)  ARCHIVE_IN_NUM FROM  (SELECT\n" +
				"\t*\n" +
				"FROM\n" +
				"\t( SELECT NVL(ARCHIVE_IN_NUM, 0 ) ARCHIVE_IN_NUM FROM " + tableName + " WHERE PARENT_ID = '"+parentId+"' "+sbSql.toString()+" ) T \n" +
				"ORDER BY\n" +
				"\tT.ARCHIVE_IN_NUM  ) T1");

		String sortStr = "";
		if (maps1 != null && maps1.size() > 0) {
			sortStr = maps1.get(0).get("ARCHIVE_IN_NUM") + "";
		}
		String[] sortArr = sortStr.split(",");
		if (sortArr.length > 0) {
			if (sortArr.length == 1 && Integer.parseInt(sortArr[0]) != 1) {
				resultMap.put("flag", 2);
				resultMap.put("disNum", 0);
				resultMap.put("nextNum", sortArr[0]);
				return resultMap;
			}
			for (int i = 1; i <= sortArr.length; i++) {
				if (Integer.parseInt(sortArr[i - 1]) != i) {
					resultMap.put("flag", 2);
					resultMap.put("disNum", i - 1);
					resultMap.put("nextNum", Integer.parseInt(sortArr[i - 1]));
					return resultMap;
				}
			}
		}



		/*List<Map<String, Object>> list = this.commTableManagerIntfsService.getCbbTableAndColumnsByTabIdByIntfs(tableId);
		String tableName = "";
		if (list.size() > 0) {
			Map<String, Object> map = list.get(0);
			tableName = (String) map.get("TABLE_NAME");
		}
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT ARCHIVE_IN_NUM AS STARTNUM,\n");
		sbSql.append("       (SELECT MIN(ARCHIVE_IN_NUM) \n");
		sbSql.append("          FROM " + tableName + "\n");
		sbSql.append("         WHERE \n");
		if (!"".equals(parentId)) {
			sbSql.append("         PARENT_ID = '" + parentId + "' AND \n");
		}
		sbSql.append("       ORG_ID = '" + orgId + "' AND SYS_ID = '" + sysId + "' AND K.ARCHIVE_IN_NUM < ARCHIVE_IN_NUM) AS ENDNUM\n");
		sbSql.append("  FROM " + tableName + " K\n");
		sbSql.append(" WHERE \n");
		if (!"".equals(parentId)) {
			sbSql.append("         PARENT_ID = '" + parentId + "' AND \n");
		}
		sbSql.append("   ORG_ID = '" + orgId + "' AND SYS_ID = '" + sysId + "' AND NOT EXISTS\n");
		sbSql.append(" (SELECT *\n");
		sbSql.append("          FROM " + tableName + "\n");
		sbSql.append("         WHERE \n");
		if (!"".equals(parentId)) {
			sbSql.append("         PARENT_ID = '" + parentId + "' AND \n");
		}
		sbSql.append("           ORG_ID = '" + orgId + "' AND SYS_ID = '" + sysId + "' AND K.ARCHIVE_IN_NUM + 1 = ARCHIVE_IN_NUM)\n");
		sbSql.append("   AND ARCHIVE_IN_NUM <\n");
		sbSql.append("       (SELECT MAX(ARCHIVE_IN_NUM)\n");
		sbSql.append("          FROM " + tableName + "\n");
		if (!"".equals(parentId)) {
			sbSql.append("         WHERE ORG_ID = '" + orgId + "' AND SYS_ID = '" + sysId + "' AND PARENT_ID = '" + parentId + "')");
		}
		sbSql.append("          ORDER BY STARTNUM ");
		List<Map<String, Object>> disList = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
		String disNum = "";
		String nextNum = "";
		if (disList.size() > 0) {
			Map<String, Object> disMap = disList.get(0);
			disNum = disMap.get("STARTNUM").toString();
			nextNum = disMap.get("ENDNUM").toString();
		}
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("DIS_NUM", disNum);
		resultMap.put("NEXT_NUM", nextNum);*/
		return resultMap;
	}

	/**
	 * 根据数据ID，获取编辑或详细，字段和数据
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param dataId
	 * @param flag
	 * @param params(p1: key=nodeId)
	 * @return
	 * @throws Exception List<Map<String,Object>>
	 * @throws
	 * huangjian
	 */
	@Override
	public List<Map<String, Object>> getEditOrDetailFieldsAndDataByIntfsItera(String orgId, String deptId, String sysId, String tableId, String dataId, String flag, Map<String, Object> params) throws Exception {
		String languageCode = "";// 当前语言code
		if (null != params && params.containsKey("languageCode")) {
			languageCode = String.valueOf(params.get("languageCode"));
		} else {
			throw new Exception("调用接口时，“languageCode”参数不存在，请检查！");
		}
		String archiveFlag = params.get("archiveFlag")==null?"":params.get("archiveFlag").toString();
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		CbbTables cbbTables = getCbbTablesById(tableId);
		List<CbbTabColumns> listc = getFormShowTableListItera(params, tableId, dataId, cbbTables.getTableName(), flag, sysId, orgId, deptId, (String) params.get("nodeId"));
		// getFormShowTableList(tableId, dataId, cbbTables.getTableName(), flag, sysId, orgId, deptId, (String) params.get("nodeId"));// 基本字段
		for (int i = 0; i < listc.size(); i++) {
			CbbTabColumns cbbTabColumns = listc.get(i);
			String languageLabel = this.commTableManagerIntfsService.getColumnLabelByColumnIdAndLanguageCode(cbbTabColumns.getId(), languageCode);
			// 如果是中文code , 并且label为空,则用系统默认label显示
			if ("zh_CN".equals(languageCode) && (null == languageLabel || "".equals(languageLabel))) {
				languageLabel = cbbTabColumns.getColLabel();
			}
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("ID", cbbTabColumns.getId());
			map.put("TABLE_ID", cbbTabColumns.getTableId());
			map.put("COL_NAME", cbbTabColumns.getColName());
			map.put("COL_LABEL", languageLabel);
			map.put("COL_TYPE", cbbTabColumns.getColType());
			map.put("COL_LENGTH", cbbTabColumns.getColLength());
			map.put("COL_DECIMAL", cbbTabColumns.getColDecimal());
			map.put("COL_IS_SYS", cbbTabColumns.getColIsSys());
			map.put("COL_ORDER", cbbTabColumns.getColOrder());
			map.put("COL_IS_MUST", cbbTabColumns.getColIsMust());
			map.put("COL_IS_VISIBLE", cbbTabColumns.getColIsVisible());
			map.put("COL_IS_SEARCH", cbbTabColumns.getColIsSearch());
			map.put("COL_IS_EDIT", cbbTabColumns.getColIsEdit());
			map.put("COL_IS_TAB_VISIBLE", cbbTabColumns.getColIsTabVisible());
			map.put("COL_IS_DETAIL", cbbTabColumns.getColIsDetail());
			map.put("COL_DROPDOWN_TYPE", cbbTabColumns.getColDropdownType());
			map.put("COL_GENE_METHOD", cbbTabColumns.getColGeneMethod());
			map.put("COL_RULE_NAME", cbbTabColumns.getColRuleName());
			map.put("COL_RULE_TITLE", cbbTabColumns.getColRuleTitle());
			map.put("CUSTOM_PATH", cbbTabColumns.getCustomPath());
			map.put("REMARK", cbbTabColumns.getRemark());
			map.put("IS_COMM_FIELD", cbbTabColumns.getIsCommField());
			if ("date".equals(cbbTabColumns.getColType()) && !"".equals(cbbTabColumns.getColValue()) && null != cbbTabColumns.getColValue()) {
				String date = "";
				if ("3".equals(archiveFlag)){ //档案保管详情页需要显示 推送时间 整理时间 检查时间 入库时间  时分秒
					if ("TSSJ".equals(cbbTabColumns.getColName())||"ZLSJ".equals(cbbTabColumns.getColName())||"JCSJ".equals(cbbTabColumns.getColName())||"RKSJ".equals(cbbTabColumns.getColName())){
						if(cbbTabColumns.getColValue()!=null&&cbbTabColumns.getColValue().indexOf(".")>-1){
							date=cbbTabColumns.getColValue().substring(0,cbbTabColumns.getColValue().indexOf("."));
						}else {
							date = cbbTabColumns.getColValue().substring(0, 10);
						}
					}else {
						date = cbbTabColumns.getColValue().substring(0, 10);
					}
				}else {
					date = cbbTabColumns.getColValue().substring(0, 10);
				}
				map.put("COL_VALUE", date);
			} else {
				map.put("COL_VALUE", cbbTabColumns.getColValue());
			}
			map.put("COL_VALUE_NAME", cbbTabColumns.getColValueName());
			// 添加组合项规则
			String colGeneMethod = cbbTabColumns.getColGeneMethod();
			if ("4".equals(colGeneMethod)) { // 组合项
				String sourceId = cbbTabColumns.getId();// 源字段ID
				String recordId = "";
				if (null != params && params.containsKey("ortherMap")) {
					Map<String, Object> ortherMap = (Map<String, Object>) params.get("ortherMap");
					Iterator it = ortherMap.keySet().iterator();
					while (it.hasNext()) {
						String key = String.valueOf(it.next());
						recordId = String.valueOf(ortherMap.get(key));
					}
				}
				// 组合项信息字符串，页面解析进行填值
				String groupConfig = getConfigStr(sourceId, tableId, recordId);
				map.put("GROUP_CONFIG", groupConfig);
			}
			list.add(map);
		}
		return list;
	}


	private String getValueByColGeneMethodRule(String colGeneMethodRule,String colGeneMethod,String colDropdownType,String colType,String orgId,String nodeId,String colName)throws Exception{
		String colValue = "";
		if ("1".equals(colGeneMethod)) { // 默认值
			if ("1".equals(colDropdownType) || "2".equals(colDropdownType)) { // 参选、只选
				// 获取通用代码
				colValue = colGeneMethodRule;
			} else if ("0".equals(colDropdownType)) { // 普通字段
				if ("string".equals(colType) || "clob".equals(colType)) {
					if ("currentQzName".equals(colGeneMethodRule)) { // 当前全宗名称
						// 根据当前组织ID查找全宗名称
						List<Map<String, Object>> qzList = getQz(orgId);
						if(qzList.size() > 0){
							Map<String, Object> qzmap = qzList.get(0);
							colValue = String.valueOf(qzmap.get("GENERAL_NAME"));
						}else{
							colValue = "";
						}
					} else if ("currentQzCode".equals(colGeneMethodRule)) { // 当前全宗代码
						// 根据当前组织ID查找全宗代码
						List<Map<String, Object>> qzList = getQz(orgId);
						if(qzList.size() > 0){
							Map<String, Object> qzmap = qzList.get(0);
							colValue = String.valueOf(qzmap.get("GENERAL_BEN_CODE"));
						}else{
							colValue = "";
						}
					} else if ("currentNodeRemark".equals(colGeneMethodRule)) { // 当前数据节点备注
						// 根据节点ID查询当前数据节点备注
						List<Map<String, Object>> flList = getNodeRemarkByNodeId(nodeId);
						if(flList.size() > 0){
							Map<String, Object> flmap = flList.get(0);
							String remark = String.valueOf(flmap.get("REMARK"));//获取当前节点备注值
							if(null != remark && !"".equals(remark) && !"null".equals(remark)){
								String[] vas = remark.split(";");
								for (int j = 0; j < vas.length; j++) {
									String va = vas[j];
									String[] v = va.split("=");
									if(v.length == 2){
										if(!"".equals(v[0]) && (colName.toUpperCase()).equals(v[0].toUpperCase())){
											colValue = v[1];
										}
									}
								}
							}
						}else{
							colValue = "";
						}
					} else {
						colValue = colGeneMethodRule;
					}
				} else if ("date".equals(colType)) {
					if ("currentDate".equals(colGeneMethodRule)) { // 当前时间
						java.util.Date dt = new java.util.Date();
						DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
						colValue = df.format(dt);
					}
				} else {
					colValue = colGeneMethodRule;
				}
				}
			}
		return colValue;
	}


	/**
	 * 根据标识条件，获取字段信息
	 *
	 * 预归档，著录整理，馆藏档案调用此方法
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param flag
	 *            （1-添加显示；2-列表显示；3-详细显示；4-查询显示）
	 * @param dataId
	 * @param params
	 *            参数列表
	 *            <ul>
	 *            <li>p1 : key = "ortherMap", 非必输 ,
	 *            Map类型，<兄弟表表ID(String)，兄弟表数据ID(String)>用于选择兄弟表组合项加载数据</li>
	 *            <li>p2 : currentUserId（String）当前用户ID, 必输</li>
	 *            <li>p3 : currentDeptId（String）当前部门ID, 必输</li>
	 *            <li>p4 : currentOrgCode（String）当前组织代码, 必输</li>
	 *            <li>p5 : userAuthsql（String）条件sql(其中包含用户权限sql), 非必输</li>
	 *            <li>p6 : wjIds（String）文件数据ID串（组卷新增案卷时有值）, 非必输</li>
	 *            <li>p7 : nodeId（String）节点ID，非必输</li>
	 *            </ul>
	 * @return
	 * @throws Exception
	 *             List<Map<String,Object>>
	 * @throws
	 * Huangjian
	 */
	@Override
	public List<Map<String, Object>> getFieldsByConditionByIntfsItera(String orgId, String deptId, String sysId, String tableId, String flag, String dataId, Map<String, Object> params) throws Exception {
		String currentUserId = "";// 当前用户ID
		if (null != params && params.containsKey("currentUserId")) {
			currentUserId = String.valueOf(params.get("currentUserId"));
		} else {
			throw new Exception("调用接口时，“currentUserId”参数不存在，请检查！");
		}
		String languageCode = "";// 当前语言code
		if (null != params && params.containsKey("languageCode")) {
			languageCode = String.valueOf(params.get("languageCode"));
		} else {
			throw new Exception("调用接口时，“languageCode”参数不存在，请检查！");
		}
		String currentDeptId = "";// 当前部门ID
		if (null != params && params.containsKey("currentDeptId")) {
			currentDeptId = String.valueOf(params.get("currentDeptId"));
		} else {
			throw new Exception("调用接口时，“currentDeptId”参数不存在，请检查！");
		}
		String parentDataId = ""; // 父级数据id(顺带父级数据用)
		if (null != params && params.containsKey("parentDataId")) {
			parentDataId = (String) params.get("parentDataId");
		}
		String nodeId = "";//当前数据节点ID
		if (null != params && params.containsKey("nodeId")) {
			nodeId = (String) params.get("nodeId");
		}
		SysDept currentDept = deptLoader.getSysDeptBySysDeptId(deptId); // 上级部门代码
		SysDept paretnDept = deptLoader.getParentSysDeptBySysDeptId(currentDeptId); // 上级部门代码
		String parentDeptId = "";
		String parentDeptCode = "";
		if (null != paretnDept) {
			parentDeptId = this.deptLoader.getParentSysDeptIdBySysDeptId(currentDeptId); // 当前部门上级部门ID
			parentDeptCode = paretnDept.getDeptCode();
		} else {
			// 如果没有上级部门，那么取当前部门
			parentDeptId = deptId;
			parentDeptCode = currentDept.getDeptCode();
		}
		String currentOrgCode = "";// 当前组织代码
		if (null != params && params.containsKey("currentOrgCode")) {
			currentOrgCode = String.valueOf(params.get("currentOrgCode"));
		} else {
			throw new Exception("调用接口时，“currentOrgCode”参数不存在，请检查！");
		}
		String userAuthsql = String.valueOf(params.get("userAuthsql"));// 条件sql
		String wjIds = String.valueOf(params.get("wjIds"));// 文件数据ID串（组卷新增案卷时有值）
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		CbbTables cbbTables = getCbbTablesById(tableId);
		List<CbbTabColumns> listc = getFormShowTableListItera(params, tableId, "", cbbTables.getTableName(), flag, sysId, orgId, deptId, nodeId);// 基本字段
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		ResultSet xlRs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			statement = conn.createStatement();
			String year = ""; // SanXiaFiles create by zhaoxiaolong 年度赋值
			for (int i = 0; i < listc.size(); i++) {
				CbbTabColumns cbbTabColumns = listc.get(i);
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("ID", listc.get(i).getId());
				map.put("TABLE_ID", cbbTabColumns.getTableId());
				map.put("COL_NAME", cbbTabColumns.getColName());
				String languageLabel = cbbTabColumns.getColLabel();
				map.put("COL_LABEL", languageLabel);
				map.put("COL_TYPE", cbbTabColumns.getColType());
				map.put("COL_LENGTH", cbbTabColumns.getColLength());
				map.put("COL_DECIMAL", cbbTabColumns.getColDecimal());
				map.put("COL_IS_SYS", cbbTabColumns.getColIsSys());
				map.put("COL_ORDER", cbbTabColumns.getColOrder());
				map.put("COL_IS_MUST", cbbTabColumns.getColIsMust());
				map.put("COL_IS_VISIBLE", cbbTabColumns.getColIsVisible());
				map.put("COL_IS_SEARCH", cbbTabColumns.getColIsSearch());
				map.put("COL_IS_EDIT", cbbTabColumns.getColIsEdit());
				map.put("COL_IS_TAB_VISIBLE", cbbTabColumns.getColIsTabVisible());
				map.put("COL_IS_DETAIL", cbbTabColumns.getColIsDetail());
				map.put("COL_DROPDOWN_TYPE", cbbTabColumns.getColDropdownType());
				map.put("COL_GENE_METHOD", cbbTabColumns.getColGeneMethod());
				map.put("COL_RULE_NAME", cbbTabColumns.getColRuleName());
				map.put("COL_RULE_TITLE", cbbTabColumns.getColRuleTitle());
				map.put("COL_GENE_METHOD_RULE", cbbTabColumns.getColGeneMethodRule());
				map.put("COL_GENE_METHOD_RULE_TEXT", cbbTabColumns.getColGeneMethodRuleText());
				map.put("CUSTOM_PATH", cbbTabColumns.getCustomPath());
				map.put("REMARK", cbbTabColumns.getRemark());
				map.put("IS_COMM_FIELD", cbbTabColumns.getIsCommField());
				// 获取字段配置信息，添加到map里(colValue,colValueName)
				String colValue = "";
				String colValueName = "";
				String colDropdownType = cbbTabColumns.getColDropdownType();
				String colRuleName = cbbTabColumns.getColRuleName();
				String colGeneMethod = cbbTabColumns.getColGeneMethod();
				String colGeneMethodRule = cbbTabColumns.getColGeneMethodRule();
				String colType = cbbTabColumns.getColType();
				String colName = cbbTabColumns.getColName();
				String customPath = cbbTabColumns.getCustomPath();// 自定义URL
				if (colName!=null&&colName.equals("YEAR")){ // SanXiaFiles create by zhaoxiaolong 赋值年度默认值
					if (year!=""&&!year.equals("")){
						colValue = year;
					}else {
						java.util.Date dt = new java.util.Date();
						DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
						colValue = df.format(dt);
						colValue = colValue.substring(0,colValue.indexOf("-"));
						colValue = colValue.replace("-","");
					}
				}
				if ("1".equals(colGeneMethod)) { // 默认值
					if ("1".equals(colDropdownType) || "2".equals(colDropdownType)) { // 参选、只选
						// 获取通用代码
						colValue = colGeneMethodRule;
					} else if ("3".equals(colDropdownType)) {
						if ("user".equals(colRuleName)) { // 选人
							if ("currentUser".equals(colGeneMethodRule)) {
								colValue = currentUserId;
								// 根据ID查找userName
								colValueName = getUserNameById(currentUserId);
							}
						} else if ("dept".equals(colRuleName)) { // 选部门
							if ("currentDept".equals(colGeneMethodRule)) { // 当前部门
								colValue = currentDeptId;
								// 根据ID查找userName
								colValueName = getDeptNameById(currentDeptId);
							} else if ("parentDept".equals(colGeneMethodRule)) {// 上级部门
								colValue = parentDeptId;
								// 根据ID查找userName
								colValueName = getDeptNameById(parentDeptId);
							}
						} else if ("custom".equals(colRuleName)) { // 自定义选择
							colValue = colGeneMethodRule;
							// 根据PATH查询相应的值
							colValueName = getCustomValue(colGeneMethodRule, customPath);
						}
					} else if ("0".equals(colDropdownType)) { // 普通字段
						if ("string".equals(colType) || "clob".equals(colType)) {
							if ("currentUser".equals(colGeneMethodRule)) { // 当前用户
								// 根据ID查找userName
								colValue = getUserNameById(currentUserId);
							} else if ("currentDeptId".equals(colGeneMethodRule)) { // 当前部门ID
								// 根据ID查找userName
								colValue = currentDeptId;
							} else if ("currentDeptName".equals(colGeneMethodRule)) { // 当前部门ID
								// 根据ID查找userName
								colValue = getDeptNameById(currentDeptId);
							} else if ("currentOrg".equals(colGeneMethodRule)) { // 当前组织
								// 根据ID查找userName
								colValue = currentOrgCode;
							} else if ("currentQzName".equals(colGeneMethodRule)) { // 当前全宗名称
								// 根据当前组织ID查找全宗名称
								List<Map<String, Object>> qzList = getQz(orgId);
								if(qzList.size() > 0){
									Map<String, Object> qzmap = qzList.get(0);
									colValue = String.valueOf(qzmap.get("GENERAL_NAME"));
								}else{
									colValue = "";
								}
							} else if ("currentQzCode".equals(colGeneMethodRule)) { // 当前全宗代码
								// 根据当前组织ID查找全宗代码
								List<Map<String, Object>> qzList = getQz(orgId);
								if(qzList.size() > 0){
									Map<String, Object> qzmap = qzList.get(0);
									colValue = String.valueOf(qzmap.get("GENERAL_BEN_CODE"));
								}else{
									colValue = "";
								}
							} else if ("currentNodeRemark".equals(colGeneMethodRule)) { // 当前数据节点备注
								// 根据节点ID查询当前数据节点备注
								List<Map<String, Object>> flList = getNodeRemarkByNodeId(nodeId);
								if(flList.size() > 0){
									Map<String, Object> flmap = flList.get(0);
									String remark = String.valueOf(flmap.get("REMARK"));//获取当前节点备注值
									if(null != remark && !"".equals(remark) && !"null".equals(remark)){
										String[] vas = remark.split(";");
										for (int j = 0; j < vas.length; j++) {
											String va = vas[j];
											String[] v = va.split("=");
											if(v.length == 2){
												if(!"".equals(v[0]) && (colName.toUpperCase()).equals(v[0].toUpperCase())){
													colValue = v[1];
												}
											}
										}
									}
								}else{
									colValue = "";
								}
							} else if ("parentDeptName".equals(colGeneMethodRule)) { // 上级部门名称
								colValue = getDeptNameById(parentDeptId);
								// 根据ID查找userName
								colValueName = getDeptNameById(parentDeptId);
							} else if ("parentDeptId".equals(colGeneMethodRule)) { // 上级部门ID
								colValue = parentDeptId;
								colValueName = parentDeptId;
							} else if ("parentDeptCode".equals(colGeneMethodRule)) { // 上级部门代码
								colValue = parentDeptCode;
								colValueName = parentDeptCode;
							} else {
								colValue = colGeneMethodRule;
							}
						} else if ("date".equals(colType)) {
							if ("currentDate".equals(colGeneMethodRule)) { // 当前时间
								java.util.Date dt = new java.util.Date();
								DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
								colValue = df.format(dt);
								// SanXiaFiles create by zhaoxiaolong 遍历字段为日期时，截取年赋值给year
								if (colName!=null&&colName.equals("RQ")){
									year = colValue.substring(0,colValue.indexOf("-"));
									year = year.replace("-","");
								}
							}
						} else {
							colValue = colGeneMethodRule;
						}
					}
				}

				if ("2".equals(colGeneMethod)) { // 序列
					String bgh = "1:QZH;ARCHIVE_CLASSNO;YEAR; ARCHIVE_MANA_PERIOD";
					if (colName.equals("BGH") && (!bgh.equals(colGeneMethodRule) || "".equals(colGeneMethodRule))) {

					}else{
						String[] colNameArg = colGeneMethodRule.substring(2, colGeneMethodRule.length()).split(";"); // 获取保管号相关字段配置项
						StringBuffer screenSql = new StringBuffer();
						for (String colForName : colNameArg) {
							colForName = colForName.trim();
							// 遍历保管号动态配置字段，获取字段对应的默认值，作为筛选条件
							for (CbbTabColumns cbbTab : listc) {
								String cbbTabName = cbbTab.getColName();
								colForName = colForName;
								if (cbbTabName.equals(colForName)) {
									String value = this.getValueByColGeneMethodRule(cbbTab.getColGeneMethodRule(), cbbTab.getColGeneMethod(), cbbTab.getColDropdownType(), cbbTab.getColType(), cbbTab.getOrgId(), nodeId, cbbTab.getColName());
									if (value != null && !value.equals("")) {
										screenSql.append(" AND " + colForName + " = '" + value + "' ");
									} else {
										if (colForName.equals("YEAR")) {
											screenSql.append(" AND " + colForName + " = '" + year + "'");
										} else {
											screenSql.append(" AND " + colForName + " IS NULL ");
										}
									}
									break;
								}
							}
						}
						String dataSqlXL = "";
						if (colNameArg.length > 0) {
							// 权限sql，找最大记录
							dataSqlXL = "SELECT CASE WHEN MAX(TO_NUMBER(" + cbbTabColumns.getColName().toUpperCase() + "))  IS NULL THEN 0 ELSE  MAX(TO_NUMBER(" + cbbTabColumns.getColName().toUpperCase() + "))  END  " + cbbTabColumns.getColName().toUpperCase() + " FROM " + cbbTables.getTableName().toUpperCase() + " WHERE 1 = 1 " + screenSql.toString();
							//SanXiaFiles update by huangjian 防止保管号类型不一致报错
							if (null != parentDataId && !"".equals(parentDataId)) {
								dataSqlXL += " AND PARENT_ID = '" + parentDataId + "'";
							}
							if (null != userAuthsql && !"".equals(userAuthsql) && !"null".equals(userAuthsql)) {
								dataSqlXL = dataSqlXL + userAuthsql;
							}
						}
						xlRs = statement.executeQuery(dataSqlXL.toString());
						while (xlRs.next()) {
							String dataValueXL = xlRs.getString(cbbTabColumns.getColName().toUpperCase());
							int count = Integer.valueOf(dataValueXL);
							dataValueXL = String.valueOf(count);
							if ("2".equals(colDropdownType)) { // 参选
								colValue = dataValueXL + colGeneMethodRule;
							} else if ("0".equals(colDropdownType)) { // 普通字段
								if ("string".equals(colType)) {
									// SanxiaFiles udate by zxl 截取步长
									colValue = stringConfig(dataValueXL, colGeneMethodRule.split(":")[0]);
								} else if ("integer".equals(colType)) {
									int cdataInteger = 0;
									if (null != dataValueXL && !"".equals(dataValueXL) && !"null".equals(dataValueXL)) {
										cdataInteger = Integer.parseInt(dataValueXL);
									}
									if (null != colGeneMethodRule && !"".equals(colGeneMethodRule) && !"null".equals(colGeneMethodRule)) {
										//sanxiaFiels create by  zbj 下面参数切割掉：之后字符串  2019.8.19
										cdataInteger = cdataInteger + Integer.parseInt(colGeneMethodRule.split(":")[0]);
										//end
									}
									colValue = String.valueOf(cdataInteger);
									// SanXiaFiles create by zhaoxiaolong 保管号整型处理 2019/12/28
									if (colName != null && colName.equals("BGH")) {
										colValue = stringConfig(dataValueXL, colGeneMethodRule.split(":")[0]);
										map.put("COL_TYPE", "string");
									}
								} else if ("float".equals(colType)) {
									float cdataFloat = 0;
									if (null != dataValueXL && !"".equals(dataValueXL) && !"null".equals(dataValueXL)) {
										cdataFloat = Float.parseFloat(dataValueXL);
									}
									if (null != colGeneMethodRule && !"".equals(colGeneMethodRule) && !"null".equals(colGeneMethodRule)) {
										cdataFloat = cdataFloat + Float.parseFloat(colGeneMethodRule.split(":")[0]);
									}
									colValue = String.valueOf(cdataFloat);
								} else if ("clob".equals(colType)) {
									colValue = dataValueXL;
									if (null != colGeneMethodRule && !"".equals(colGeneMethodRule) && !"null".equals(colGeneMethodRule)) {
										colValue = colValue + colGeneMethodRule;
									}
								}
							}
						}
					}
				}
				if ("3".equals(colGeneMethod)) { // 顺带
					String geneMethodRule = cbbTabColumns.getColGeneMethodRule();
					String searchTableId = "";
					String searchColId = "";
					if (null == geneMethodRule || "".equals(geneMethodRule) || "null".equals(geneMethodRule)) {
						searchTableId = cbbTabColumns.getTableId();
						searchColId = cbbTabColumns.getId();
					} else {
						String[] geneMethodRules = geneMethodRule.split(",");
						searchTableId = geneMethodRules[0];
						searchColId = geneMethodRules[1];
					}
					CbbTables ct = this.getCbbTablesById(searchTableId);

					List<Map<String, Object>> columnList = this.commTableManagerIntfsService.getCbbColumnsByColIdByIntfs(searchColId);
					Map<String, Object> columnMap = new HashMap<String, Object>();
					if (columnList.size() > 0) {
						columnMap.putAll(columnList.get(0));
					}
					String searchDataId = "";
					if (searchTableId.equals(cbbTabColumns.getTableId())) {
						if (!"".equals(dataId)) {
							searchDataId = dataId;
						}
					} else {
						if (!"".equals(parentDataId)) {
							searchDataId = parentDataId;
						}
					}
					if (!"".equals(searchDataId)) {
						String dataValue = "";
						// 根据选中数据ID获取数据对象
						String dataSql = "SELECT T.* FROM " + ct.getTableName() + " T WHERE T.ID = '" + searchDataId + "'";
						rs = statement.executeQuery(dataSql.toString());
						while (rs.next()) {
							dataValue = rs.getString((String) columnMap.get("COL_NAME"));
							if (null != dataValue && !"".equals(dataValue) && !"null".equals(dataValue)) {
								if ("3".equals(colDropdownType)) {
									if ("user".equals(colRuleName)) { // 选人
										colValue = dataValue;
										colValueName = getUserNameById(dataValue);
										if ("".equals(colValueName)) {
											colValueName = colValue;
										}
									} else if ("dept".equals(colRuleName)) { // 选部门
										colValue = dataValue;
										colValueName = getDeptNameById(dataValue);
										if ("".equals(colValueName)) {
											colValueName = colValue;
										}
									} else if ("custom".equals(colRuleName)) { // 自定义选择
										colValueName = getCustomValue(dataValue, customPath);
									}
								} else { // 下拉类型，普通字段
									if ("date".equals(colType)) {
										if (null != dataValue && !"".equals(dataValue) && !"null".equals(dataValue)) {
											colValue = dataValue.substring(0, 10);
										} else {
											colValue = "";
										}
									} else {
										colValue = dataValue;
									}
								}
							}
						}
					}
				}
				if ("4".equals(colGeneMethod)) { // 组合项
					String sourceId = cbbTabColumns.getId();// 源字段ID
					String recordId = "";
					if (null != params && params.containsKey("ortherMap")) {
						Map<String, Object> ortherMap = (Map<String, Object>) params.get("ortherMap");
						Iterator it = ortherMap.keySet().iterator();
						while (it.hasNext()) {
							String key = String.valueOf(it.next());
							recordId = String.valueOf(ortherMap.get(key));
						}
					}
					// 组合项信息字符串，页面解析进行填值
					String groupConfig = getConfigStr(sourceId, tableId, recordId);
					map.put("GROUP_CONFIG", groupConfig);
				}
				if ("5".equals(colGeneMethod)) { // 组卷时新建案卷将配置为统计生成的字段值计算出来并在页面显示
					if (null != wjIds && !"".equals(wjIds) && !"null".equals(wjIds)) {
						// 获取字段配置的统计生成信息
						String configSql = "SELECT T.GROUP_ORDER,T.TARGET_TABLE_ID,T.TARGET_COLUMN_ID,T.TARGET_INPUT,T.TARGET_COLUMN_OPERATION FROM CBB_TAB_COL_CONFIG_GROUP T WHERE T.SOURCE_TABLE_ID = '" + tableId + "' AND T.SOURCE_COLUMN_ID = '" + cbbTabColumns.getId() + "'";
						List<Object[]> configList = this.hibernateDao.findBySQL(configSql);
						if (configList.size() > 0) {
							String order = "";
							String tgtTabId = "";
							String colId1 = "";
							String colId2 = "";
							String colId3 = "";
							String input1 = "";
							String input2 = "";
							String operation = "";
							for (int j = 0; j < configList.size(); j++) {
								order = String.valueOf(configList.get(j)[0]);
								tgtTabId = String.valueOf(configList.get(j)[1]);
								operation = String.valueOf(configList.get(j)[4]);
								if ("1".equals(order)) {
									colId1 = String.valueOf(configList.get(j)[2]);
									input1 = String.valueOf(configList.get(j)[3]);
								} else if ("2".equals(order)) {
									colId2 = String.valueOf(configList.get(j)[2]);
									input2 = String.valueOf(configList.get(j)[3]);
								} else if ("3".equals(order)) {
									colId3 = String.valueOf(configList.get(j)[2]);
								}
							}
							// 根据统计生成配置信息计算值(此处为组卷时计算值没有ajDataId,但算值方法该参数是必须的,所以传入表ID)
							String configValue = "";
							// 直接传入计算值(此处为组卷时计算值没有ajDataId,但算值方法该参数是必须的,所以传入表ID)
							configValue = getValueByconfig(tableId, tgtTabId, colId1, colId2, colId3, input1, input2, operation, colType, orgId, deptId, sysId, tableId, wjIds);
							// 对“null”处理
							if (null == configValue || "null".equals(configValue)) {
								configValue = "";
							}
							// 根据字段类型填值
							if (null != configValue && !"".equals(configValue) && !"null".equals(configValue)) {
								colValue = configValue;
							}
						}
					}
				}
				map.put("COL_VALUE", colValue);
				map.put("COL_VALUE_NAME", colValueName);
				list.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("数据库操作异常，请联系管理员！");
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (xlRs != null) {
				try {
					xlRs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return list;
	}

	/**
	 * 根据表ID以及查询条件，获取表的列信息以及数据
	 *
	 * @author HuangJian
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param pageNo
	 * @param pageSize
	 * @param serachCondition
	 * @param param
	 *            (p1:[key:searchOrder
	 *            value:LinkedHashMap<String(字段英文名),String(排序策略：{ASC,DESC}>])
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<Map<String, Object>> getTableFieldsAndDatasBySearchByOrderbyByIntfsItera(String orgId, String deptId, String sysId, String tableId, String pageNo, String pageSize, String serachCondition, Map<String, Object> param) throws Exception {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		String sql = "";
		CbbTables cbbTables = getCbbTablesById(tableId);
		// 获取条目是否存在附件状态
		if (null != param && param.containsKey("ATTACH_STATUS") && null != param.get("ATTACH_STATUS") && !"".equals(param.get("ATTACH_STATUS")) && ("1".equals(param.get("ATTACH_STATUS")) || "2".equals(param.get("ATTACH_STATUS")))) {
			sql = "SELECT * FROM (SELECT (SELECT COUNT(1) FROM CBB_DOC_RELATION CDR WHERE CDR.RECORD_ID = T.ID AND CDR.IF_DELETE = 'N') ATTACH_COUNT, T.* FROM " + cbbTables.getTableName() + " T WHERE 1=1 ";
		} else {
			sql = "SELECT * FROM " + cbbTables.getTableName() + " WHERE 1=1 ";
		}
		if (!"".equals(serachCondition)) {
			sql = sql + serachCondition + "  ";
		}
		// 获取排序字段
		if (null != param && param.containsKey("searchOrder")) {
			LinkedHashMap<String, String> orderMap = (LinkedHashMap<String, String>) param.get("searchOrder");
			if (orderMap.size() > 0) {
				// 取自定义排序
				int orderIndex = 0;
				Iterator orderIt = orderMap.keySet().iterator();
				while (orderIt.hasNext()) {
					String orderCol = String.valueOf(orderIt.next());// 排序字段英文名
					String orderRule = orderMap.get(orderCol);// 排序规则
					if (null != orderCol && !"".equals(orderCol) && !"null".equals(orderCol) && ("ASC".equals(orderRule) || "DESC".equals(orderRule))) {
						if (orderIndex == 0) {
							sql = sql + " ORDER BY " + orderCol + " " + orderRule + ",";
						} else {
							sql = sql + orderCol + " " + orderRule + ",";
						}
						orderIndex++;
					}
				}
			} else {
				// 默认取库结构配置排序
				List<Map<String, Object>> sortlist = commTableManagerIntfsService.getColDataOrderByTableId(tableId, sysId, orgId, deptId);
				for (int i = 0; i < sortlist.size(); i++) {
					if (i == 0) {
						sql = sql + " ORDER BY ";
					}
					Map<String, Object> sortMap = sortlist.get(i);
					String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
					String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
					// A-升序，D-降序
					if ("A".equals(sortCode)) {
						sortCode = " ASC";
					} else {
						sortCode = " DESC";
					}
					sql = sql + colName + sortCode + ",";
				}
			}
		} else {
			// 默认取库结构配置排序
			List<Map<String, Object>> sortlist = commTableManagerIntfsService.getColDataOrderByTableId(tableId, sysId, orgId, deptId);
			for (int i = 0; i < sortlist.size(); i++) {
				if (i == 0) {
					sql = sql + " ORDER BY ";
				}
				Map<String, Object> sortMap = sortlist.get(i);
				String colName = String.valueOf(sortMap.get("COL_NAME"));// 字段名
				String sortCode = String.valueOf(sortMap.get("SORT_CODE"));// 排序规则
				// A-升序，D-降序
				if ("A".equals(sortCode)) {
					sortCode = " ASC";
				} else {
					sortCode = " DESC";
				}
				sql = sql + colName + sortCode + ",";
			}
		}
		sql = sql.substring(0, sql.length() - 1);
		// List<CbbTabColumns> formShowList = getFormShowTableList(tableId, "", cbbTables.getTableName(), "0", sysId, orgId, deptId, "");// 全部字段对象
		List<CbbTabColumns> formShowList = getFormShowTableListItera(param, tableId, "", cbbTables.getTableName(), "1", sysId, orgId, deptId, "");// 全部字段对象

		// add start by zyh 2015.06.15
		List<String> colIds = new ArrayList<String>();
		StringBuffer queryLookupSql = new StringBuffer();
		queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
		queryLookupSql.append(" WHERE T.COLUMN_ID IN (");
		// 获得存在通用代码列的列id
		for (int i = 0; i < formShowList.size(); i++) {
			CbbTabColumns ctcs = formShowList.get(i);
			if ("1".equals(ctcs.getColDropdownType()) || "2".equals(ctcs.getColDropdownType())) {
				queryLookupSql.append("'" + ctcs.getId() + "',");
				colIds.add(ctcs.getId());
			}
		}
		String querySql = "";
		if (queryLookupSql.toString().endsWith(",")) {
			querySql = queryLookupSql.substring(0, queryLookupSql.length() - 1) + ")";
		}
		// 查询出列中所需通用代码
		List<Map<String, Object>> lookupList = new ArrayList<Map<String, Object>>();
		if (colIds.size() > 0) {
			lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(querySql);
		}
		// 创建通用代码map便于赋值
		Map<String, Map<String, String>> lookupMapKeyValue = new HashMap<String, Map<String, String>>();
		for (int i = 0; i < colIds.size(); i++) {
			Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
			for (int j = 0; j < lookupList.size(); j++) {
				Map<String, Object> lookupMap = lookupList.get(j);
				if (colIds.get(i).equals(lookupMap.get("COLUMN_ID"))) {
					lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
				}
			}
			lookupMapKeyValue.put(colIds.get(i), lookupNameCodeMap);
		}
		// add end by zyh 2015.06.15
		if (null != param && param.containsKey("ATTACH_STATUS") && null != param.get("ATTACH_STATUS") && !"".equals(param.get("ATTACH_STATUS"))) {
			if ("1".equals(param.get("ATTACH_STATUS"))) {
				sql += ") WHERE ATTACH_COUNT > 0";
			} else if ("2".equals(param.get("ATTACH_STATUS"))) {
				sql += ") WHERE ATTACH_COUNT < 1";
			}
		}
		// 构造PAGE对象
		String sqlPage = "";
		String sqlCount = "SELECT COUNT(1) FROM (" + sql + ")";
		long count = 0;
		if (!"".equals(pageNo) && !"".equals(pageSize) && !"0".equals(pageNo) && !"0".equals(pageSize)) {
			Paging<CbbTabColumns> page = new Paging<CbbTabColumns>();
			page.setPageSize(ComUtil.getPageSize(pageSize));
			page.setPageNo(ComUtil.getPageNo(pageNo));
			Page<Map<String, Object>> pageBean = new Page<Map<String, Object>>(page.getPageNo(), page.getPageSize());
			int firstResult = pageBean.getFirstEntityIndex();
			int maxResults = pageBean.getRows();
			if (firstResult <= 0) {
				sqlPage = "select * from ( " + sql + " ) where rownum <= " + maxResults;
			} else {
				sqlPage = "select * from ( select row_.*, rownum rownum_var from ( " + sql + " ) row_) where rownum_var > " + firstResult + " and rownum_var <= " + (firstResult + maxResults);
			}
		} else {
			sqlPage = sql;
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接

			statement = conn.createStatement();
			rs = statement.executeQuery(sqlCount);
			while (rs.next()) {
				count = rs.getLong(1);
			}
			rs = statement.executeQuery(sqlPage);
			int num = 0;
			while (rs.next()) {
				Map<String, Object> map = new HashMap<String, Object>();
				if (num == 0) {
					map.put("ROW_COUNT", count);
				}
				num++;
				// 循环基本字段进行赋值
				for (int i = 0; i < formShowList.size(); i++) {
					String cValue = "";// 具体的值
					String colName = formShowList.get(i).getColName();// 列名
					String colType = formShowList.get(i).getColType();// 列类型
					String colRuleName = formShowList.get(i).getColRuleName();// 列规则名称
					if ("string".equals(colType)) {
						cValue = rs.getString(colName);
					} else if ("integer".equals(colType)) {
						cValue = rs.getString(colName);
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("date".equals(colType)) {
						cValue = rs.getDate(colName) + "";
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("float".equals(colType)) {
						cValue = rs.getString(colName);
						cValue = "null".equals(cValue) ? "" : cValue;
					} else if ("clob".equals(colType)) {
						Clob clobInData = rs.getClob(colName);
						if (null != clobInData) {
							int clobLength = (int) clobInData.length();
							cValue = clobInData.getSubString(1, clobLength);
						}
					}
					if ("1".equals(formShowList.get(i).getColDropdownType()) || "2".equals(formShowList.get(i).getColDropdownType())) {

						// add start by zyh 2015.06.15
						Map<String, String> showLookupMap = lookupMapKeyValue.get(formShowList.get(i).getId());
						map.put(colName, showLookupMap.get(cValue) == null ? cValue : showLookupMap.get(cValue));
						map.put(colName + "_CODE", cValue);
						// add end by zyh 2015.06.15
					} else if ("user".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String[] users = cValue.split(",");
							String usersName = "";
							String userId = "";
							for (int q = 0; q < users.length; q++) {
								if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
									SysUser su = userLoader.getSysUserById(users[q]);
									if (null != su) {
										usersName = usersName + su.getName() + ",";
										userId = userId + users[q] + ",";
									} else {
										usersName = usersName + users[q] + ",";
										userId = userId + users[q] + ",";
									}
								}
							}
							usersName = usersName.substring(0, usersName.length() - 1);
							userId = userId.substring(0, userId.length() - 1);
							map.put(colName, usersName);
							map.put(colName + "_CODE", userId);
						}
					} else if ("dept".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String[] depts = cValue.split(",");
							String deptName = "";
							String deptIds = "";
							for (int q = 0; q < depts.length; q++) {
								if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
									SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
									if (null != sdt) {
										deptName = deptName + sdt.getDeptName() + ",";
										deptIds = deptIds + depts[q] + ",";
									} else {
										deptName = deptName + depts[q] + ",";
										deptIds = deptIds + depts[q] + ",";
									}
								}
							}
							deptName = deptName.substring(0, deptName.length() - 1);
							deptIds = deptIds.substring(0, deptIds.length() - 1);
							map.put(colName, deptName);
							map.put(colName + "_CODE", deptIds);
						}
					} else if ("custom".equals(colRuleName)) {
						if (!"".equals(cValue) && null != cValue && !"null".equals(cValue)) {
							String path = formShowList.get(i).getCustomPath();// 获取自定义页面路径
							// 截取表名，字段值
							if (!"".equals(path) && null != path) {
								String[] url = path.split("[?]");
								if (url.length > 1) {
									String[] arg = url[1].split("&");// 表名，字段值字符串
									if (arg.length > 1) {
										String cNames = "";// 返回的显示值字符串
										String tName = arg[0].split("=")[1];// 表名
										String cName = arg[1].split("=")[1];// 列名
										StringBuffer sbSqlCustom = new StringBuffer();
										sbSqlCustom.append("SELECT T." + cName + "\n");
										sbSqlCustom.append("  FROM " + tName + " T\n");
										sbSqlCustom.append(" WHERE T.ID IN (");
										String[] datas = cValue.split(",");
										for (int d = 0; d < datas.length; d++) {
											if (d == datas.length - 1) {
												sbSqlCustom.append("'" + datas[d] + "'\n");
											} else {
												sbSqlCustom.append("'" + datas[d] + "',\n");
											}
										}
										sbSqlCustom.append(")");
										// JDBC实现
										// 查询列的值，并且给attribute02赋值
										Statement statements = null;
										ResultSet rss = null;
										try {
											statements = conn.createStatement();
											rss = statements.executeQuery(sbSqlCustom.toString());
											while (rss.next()) {
												cNames = cNames + rss.getString(cName) + ",";
											}
											if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
												cNames = cNames.substring(0, cNames.length() - 1);
											}
											map.put(colName, cNames);
										} catch (Exception e) {
											e.printStackTrace();
											throw new Exception("数据库操作异常，请联系管理员！");
										} finally {
											if (rss != null) {
												try {
													rss.close();
													rss = null;
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
											if (statements != null) {
												try {
													statements.close();
													statements = null;
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
										}
									}
								}
							}
						}
					} else {
						map.put(colName, cValue);
					}
				}
				map.put("ID", rs.getString("ID"));
				map.put("LANTOP_FJ_RCD_ID", rs.getString("ID"));
				list.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					// conn.close();
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		if (null != commTableSysFieldLoader.getAttachmentClassName() && !"".equals(commTableSysFieldLoader.getAttachmentClassName())) {
			this.fileUploadIntfsService.getAttachClassification(list);
		}
		return list;
	}
	/**
	 * @Title: getFormShowTableListItera
	 * @Description: 获取基本基本字段对象集合
	 * 预归档，整理归档，已归档 根据不同的类型查询不同的显示字段
	 * @param params 参数集合  1预归档，2整理归档，3已归档
	 * @param tableId
	 * @param id
	 * @param tableName
	 * @param flag
	 * @param sysId
	 * @param orgId
	 * @param deptId
	 * @param nodeId
	 * @return java.util.List<avicit.cbb.techclass.tabledefine.commtablemanager.domain.CbbTabColumns>
	 * @date 2019-08-01
	 * @author HuangJian
	 */
	public List<CbbTabColumns> getFormShowTableListItera(Map<String, Object> params, String tableId, String id, String tableName, String flag, String sysId, String orgId, String deptId, String nodeId) throws Exception {
		// flag 1-是否添加或编辑显示 2-是否列表显示 3-是否详细显示 4-是否查询显示 0-全部字段显示
		// 当前数据的归档状态 0预归档 1整理归档
		//标识 0普通 1预归档 ，2著录，3馆藏
		String fromarchiveStatus = "";//
		if(null != params && params.containsKey("archiveFlag")){
			fromarchiveStatus = String.valueOf(params.get("archiveFlag"));
		}
		// 判断是否存在表单管理信息
		boolean flagform = false;
		StringBuffer sbSqls = new StringBuffer();
		if (!StringUtils.isEmpty(id)) {
			/*
			 * 判断fromarchiveStatus 是否为空
			 * 为空：  判断普通是否为空
			 * 判断普通时是否为空：
			 * 为空：走库结构定义
			 * 不为空：走普通
			 * */
			if(StringUtils.isEmpty(fromarchiveStatus)){//如果fromarchiveStatus为空 先检查 0普通是否存在
				sbSqls.append("SELECT COUNT(1)\n");
				sbSqls.append("  FROM CBB_TAB_FORM_CONFIG CTFC\n");
				sbSqls.append(" INNER JOIN CBB_TAB_FORM CTF ");
				sbSqls.append(" ON CTFC.FORM_ID = CTF.ID ");
				sbSqls.append("  LEFT JOIN CBB_TAB_COLUMNS CTC\n");
				sbSqls.append("    ON CTC.ID = CTFC.COLUMN_ID\n");
				sbSqls.append(" WHERE CTF.ARCHIVE_STATUS = '0'");
				sbSqls.append(" AND CTC.TABLE_ID = '" + tableId + "'");
			}else{
				sbSqls.append("SELECT COUNT(1)\n");
				sbSqls.append("  FROM CBB_TAB_FORM_CONFIG CTFC\n");
				sbSqls.append(" INNER JOIN CBB_TAB_FORM CTF ");
				sbSqls.append(" ON CTFC.FORM_ID = CTF.ID ");
				sbSqls.append("  LEFT JOIN CBB_TAB_COLUMNS CTC\n");
				sbSqls.append("    ON CTC.ID = CTFC.COLUMN_ID\n");
				sbSqls.append(" WHERE CTF.ARCHIVE_STATUS = '" + fromarchiveStatus + "'");
				sbSqls.append(" AND CTC.TABLE_ID = '" + tableId + "'");
			}
		} else {
			if (!StringUtils.isEmpty(fromarchiveStatus)) {
				sbSqls.append("SELECT COUNT(1)\n");
				sbSqls.append("  FROM CBB_TAB_FORM_CONFIG CTFC\n");
				sbSqls.append(" INNER JOIN CBB_TAB_FORM CTF ");
				sbSqls.append(" ON CTFC.FORM_ID = CTF.ID ");
				sbSqls.append("  LEFT JOIN CBB_TAB_COLUMNS CTC\n");
				sbSqls.append("    ON CTC.ID = CTFC.COLUMN_ID\n");
				sbSqls.append(" WHERE CTF.ARCHIVE_STATUS = '" + fromarchiveStatus + "'");
				sbSqls.append(" AND CTC.TABLE_ID = '" + tableId + "'");
			} else {
				sbSqls.append("SELECT COUNT(1)\n");
				sbSqls.append("  FROM CBB_TAB_FORM_CONFIG CTFC\n");
				sbSqls.append("  LEFT JOIN CBB_TAB_COLUMNS CTC\n");
				sbSqls.append("    ON CTC.ID = CTFC.COLUMN_ID\n");
				sbSqls.append(" WHERE CTC.TABLE_ID = '" + tableId + "'");
			}
		}

		List<Object> numList = hibernateDao.findBySQL(sbSqls.toString());
		int num = Integer.parseInt(String.valueOf(numList.get(0)));
		if (num > 0) {
			flagform = true;
		}
		StringBuffer sbSql = new StringBuffer();
		if(flagform && !StringUtils.isEmpty(fromarchiveStatus)){
			// flag 1-是否添加或编辑显示 2-是否列表显示 3-是否详细显示 4-是否查询显示 0-全部字段显示
			if (!"2".equals(flag) && !"0".equals(flag)) {
				// 存在并且不为表格时    ATTRIBUTE_11 表单顺序
				sbSql.append("SELECT T.COLUMN_ID,  \n");
				sbSql.append(" T.ATTRIBUTE_01,T.ATTRIBUTE_02,T.ATTRIBUTE_03,T.ATTRIBUTE_04,T.COL_IS_DETAIL \n ");
				sbSql.append(" FROM (SELECT DISTINCT CTFC.COLUMN_ID,CTFC.ATTRIBUTE_11, CTC.COL_NAME,\n");
				//SanXiaFiles update by huangjian 2019-11-05
				//ATTRIBUTE_01:是否必著，ATTRIBUTE_02：是否表格显示，ATTRIBUTE_03：是否添加/编辑显示，
				// ATTRIBUTE_04：是否详细显示
				sbSql.append(" CTFC.ATTRIBUTE_01,CTFC.ATTRIBUTE_02,CTFC.ATTRIBUTE_03,CTFC.ATTRIBUTE_04,CTFC.COL_IS_DETAIL \n ");
				sbSql.append("  FROM CBB_TAB_FORM_CONFIG CTFC\n");
				sbSql.append(" INNER JOIN CBB_TAB_FORM CTF ");
				sbSql.append(" ON CTFC.FORM_ID = CTF.ID ");
				sbSql.append("  LEFT JOIN CBB_TAB_COLUMNS CTC\n");
				sbSql.append("    ON CTC.ID = CTFC.COLUMN_ID\n");
				sbSql.append(" WHERE 1=1 ");
				if (!StringUtils.isEmpty(fromarchiveStatus)) {
					sbSql.append(" AND CTF.ARCHIVE_STATUS = '" + fromarchiveStatus + "'");
				}
				sbSql.append(" AND CTC.TABLE_ID = '" + tableId + "'");
				sbSql.append(" ) T\n ");
				sbSql.append(" ORDER BY T.ATTRIBUTE_11, T.COL_NAME");
			} else {
				//SanXiaFiles update by huangjian 为表格时  表格排序  ATTRIBUTE_12 表格顺序
				sbSql.append("SELECT T.COLUMN_ID, \n");
				sbSql.append(" T.ATTRIBUTE_01,T.ATTRIBUTE_02,T.ATTRIBUTE_03,T.ATTRIBUTE_04,T.COL_IS_DETAIL \n ");
				sbSql.append(" FROM (SELECT DISTINCT CTFC.COLUMN_ID,CTFC.ATTRIBUTE_12, CTC.COL_NAME, \n ");
				//ATTRIBUTE_11:是否必著，ATTRIBUTE_02：是否表格显示，ATTRIBUTE_03：是否添加/编辑显示，
				// ATTRIBUTE_04：是否详细显示
				sbSql.append(" CTFC.ATTRIBUTE_01,CTFC.ATTRIBUTE_02,CTFC.ATTRIBUTE_03,CTFC.ATTRIBUTE_04,CTFC.COL_IS_DETAIL \n ");

				sbSql.append("  FROM CBB_TAB_FORM_CONFIG CTFC\n");
				sbSql.append(" INNER JOIN CBB_TAB_FORM CTF ");
				sbSql.append(" ON CTFC.FORM_ID = CTF.ID ");
				sbSql.append("  LEFT JOIN CBB_TAB_COLUMNS CTC\n");
				sbSql.append("    ON CTC.ID = CTFC.COLUMN_ID\n");
				sbSql.append(" WHERE 1=1 ");
				if (!StringUtils.isEmpty(fromarchiveStatus)) {
					sbSql.append(" AND CTF.ARCHIVE_STATUS = '" + fromarchiveStatus + "'");
				}
				sbSql.append(" AND CTC.TABLE_ID = '" + tableId + "'  ");
				sbSql.append(" ) T\n ");
				sbSql.append(" ORDER BY T.ATTRIBUTE_12, T.COL_NAME");
			}
		}else{
			//SanXiaFiles update by huangjian start
			if("2".equals(flag)){//库结构定义中的表格顺序
				sbSql.append("SELECT T.ID AS COLUMN_ID \n");
				sbSql.append("  FROM CBB_TAB_COLUMNS T\n");
				sbSql.append(" WHERE T.TABLE_ID = '" + tableId + "'\n");
				sbSql.append(" ORDER BY T.ATTRIBUTE_11,T.COL_NAME");
				//SanXiaFiles update by huangjian end
			}else{//库结构定义中的表单排序
				sbSql.append("SELECT T.ID AS COLUMN_ID\n");
				sbSql.append("  FROM CBB_TAB_COLUMNS T\n");
				sbSql.append(" WHERE T.TABLE_ID = '" + tableId + "'\n");
				sbSql.append(" ORDER BY T.COL_ORDER,T.COL_NAME");
			}

		}
		List<CbbTabColumns> cbbTabColumnsList = new ArrayList<CbbTabColumns>();
		//List<Object> objList = hibernateDao.findBySQL(sbSql.toString());
		//SanXiaFiles update by huangjian
		//List<Map<String,Object>> objList = hibernateDao.findBySQL(sbSql.toString());
		List<Map<String,Object>> objList =jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
		tableName = tableName.toUpperCase();
		String tabNodeId = "";
		List<Map<String, Object>> nodeRecordList = new ArrayList<Map<String, Object>>();
		if (null != nodeId && !"".equals(nodeId) && !"null".equals(nodeId)) {
			// 调用rest服务，查找节点著录定义配置信息，如果有配置信息，覆盖旧值
			tabNodeId = getCbbTabNodeIdByTableId(sysId, tableId, nodeId);
		}
		if (null != tabNodeId && !"".equals(tabNodeId) && !"null".equals(tabNodeId)) {
			nodeRecordList = getTabNodeRecordInfoByTabNodeId(tabNodeId);
		}
		// 连接池
		DBConnectionCustomManager connectionMan = null;
		String poolName = orgId + "_" + sysId;
		Connection conn = null;
		Statement statement = null;
		ResultSet rs = null;
		try {
			// 实例化连接池
			connectionMan = DBConnectionCustomManager.getInstance(poolName);
			// 获取连接
			conn = connectionMan.getConnection(poolName);// 根据连接池名称从连接池中获取连接
			//statement = conn.createStatement();

			//-----------------------------SanXiaFiles update by huangjian
			Map<String,Object> colDataMap = new HashMap<>();//存tableName的一条数据
			StringBuffer sbSqlCol = new StringBuffer();
			sbSqlCol.append("SELECT * FROM " + tableName);
			if (!"".equals(id)) {
				sbSqlCol.append(" WHERE ID = '" + id + "'");
				colDataMap = jdbcAvicit.getJdbcTemplate().queryForMap(sbSqlCol.toString());
			}
			//------------------------------SanXiaFiles update by huangjian  end
			for (int i = 0; i < objList.size(); i++) {
				Map<String,Object> colInfo = objList.get(i);
				String cid = String.valueOf(colInfo.get("COLUMN_ID"));
				//String cid = String.valueOf(objList.get(i));
				// CbbTabColumns cbbTabColumns = new CbbTabColumns();
				CbbTabColumns cbbTabColumns = getCbbTabColumnsById(cid);
				cbbTabColumns.setColName(cbbTabColumns.getColName().toUpperCase());
				if (nodeRecordList != null && nodeRecordList.size() > 0) {
					for (Map<String, Object> nodeRecordMap : nodeRecordList) {
						String colId = (String) nodeRecordMap.get("COLUMN_ID");
						String isVisible = (String) nodeRecordMap.get("COL_IS_VISIBLE");
						String isTabVisible = (String) nodeRecordMap.get("COL_IS_TAB_VISIBLE");
						String isDetail = (String) nodeRecordMap.get("COL_IS_DETAIL");
						String isSearch = (String) nodeRecordMap.get("COL_IS_SEARCH");
						if (cid.equals(colId)) {
							cbbTabColumns.setColIsVisible(isVisible);
							cbbTabColumns.setColIsTabVisible(isTabVisible);
							cbbTabColumns.setColIsDetail(isDetail);
							cbbTabColumns.setColIsSearch(isSearch);
						}
					}
				}
				// 根据ID，COLNAME去实体表中查询该字段的数据信息，供前台使用
				String cdata = "";// 数据字符串
				String colName = cbbTabColumns.getColName().toUpperCase();
				String colRuleName = cbbTabColumns.getColRuleName();
				cbbTabColumns.setIsCommField("N");
				//sbSqlCol.append("SELECT " + colName + " FROM " + tableName);
				if (!"".equals(id)) {
					//SanXiaFiles updae by huangjian---优化
					if (!"".equals(colDataMap.get(colName)) && !"null".equals(colDataMap.get(colName)) && null != colDataMap.get(colName)) {
						cdata = cdata + colDataMap.get(colName) + ",";
					}
					//SanXiaFiles update by huangjian start  end
					if (!"".equals(cdata)) {
						cdata = cdata.substring(0, cdata.length() - 1);
					}
					// 给colValueName字段充数据值----user&&dept&&custom
					if ("user".equals(colRuleName)) {
						if (!"".equals(cdata) && null != cdata && !"null".equals(cdata)) {
							String[] users = cdata.split(",");
							String usersName = "";
							for (int q = 0; q < users.length; q++) {
								if (!"".equals(users[q]) && null != users[q] && !"null".equals(users[q])) {
									SysUser su = userLoader.getSysUserById(users[q]);
									if (null != su) {
										usersName = usersName + su.getName() + ",";
									} else {
										usersName = usersName + users[q] + ",";
									}
								}
							}
							if (!"".equals(usersName)) {
								usersName = usersName.substring(0, usersName.length() - 1);
							}
							/**** 2015/07/24增加 - 郭亮 （配置统计生成时根据配置信息计算后的值不在原数据源中） *****/
							if (!"".equals(usersName)) {
								cbbTabColumns.setColValueName(usersName);
							} else {
								cbbTabColumns.setColValueName(cdata);
							}
							/**** 2015/07/24增加 - 郭亮 （配置统计生成时根据配置信息计算后的值不在原数据源中） *****/
						} else {
							String colValue = (String) colDataMap.get(colName);
							cbbTabColumns.setColValueName(colValue);
						}
					} else if ("dept".equals(colRuleName)) {
						if (!"".equals(cdata) && null != cdata && !"null".equals(cdata)) {
							String[] depts = cdata.split(",");
							String deptName = "";
							for (int q = 0; q < depts.length; q++) {
								if (!"".equals(depts[q]) && null != depts[q] && !"null".equals(depts[q])) {
									SysDeptTl sdt = deptLoader.getSysDeptTl(depts[q], "zh_CN");
									if (null != sdt) {
										deptName = deptName + sdt.getDeptName() + ",";
									} else {
										deptName = deptName + depts[q] + ",";
									}
								}
							}
							if (!"".equals(deptName)) {
								deptName = deptName.substring(0, deptName.length() - 1);
							}
							/**** 2015/07/24增加 - 郭亮 （配置统计生成时根据配置信息计算后的值不在原数据源中） *****/
							if (!"".equals(deptName)) {
								cbbTabColumns.setColValueName(deptName);
							} else {
								cbbTabColumns.setColValueName(cdata);
							}
							/**** 2015/07/24增加 - 郭亮 （配置统计生成时根据配置信息计算后的值不在原数据源中） *****/
						}
					} else if ("custom".equals(colRuleName)) {
						if (!"".equals(cdata) && null != cdata && !"null".equals(cdata)) {
							String path = cbbTabColumns.getCustomPath();// 获取自定义页面路径
							// 截取表名，字段值
							if (!"".equals(path) && null != path) {
								String[] url = path.split("[?]");
								if (url.length > 1) {
									String[] arg = url[1].split("&");// 表名，字段值字符串
									if (arg.length > 1) {
										String cNames = "";// 返回的显示值字符串
										String tName = arg[0].split("=")[1];// 表名
										String cName = arg[1].split("=")[1];// 列名
										// JDBC实现
										// 查询列的值，并且给attribute02赋值
										statement = conn.createStatement();
										StringBuffer sbSqlCustom = new StringBuffer();
										sbSqlCustom.append("SELECT T." + cName + "\n");
										sbSqlCustom.append("  FROM " + tName + " T\n");
										sbSqlCustom.append(" WHERE T.ID IN (");
										String[] datas = cdata.split(",");
										for (int d = 0; d < datas.length; d++) {
											if (d == datas.length - 1) {
												sbSqlCustom.append("'" + datas[d] + "'\n");
											} else {
												sbSqlCustom.append("'" + datas[d] + "',\n");
											}
										}
										sbSqlCustom.append(")");
										ResultSet rss = null;
										Statement statements = null;
										try {
											statements = conn.createStatement();
											rss = statements.executeQuery(sbSqlCustom.toString());
											while (rss.next()) {
												cNames = cNames + rss.getString(cName) + ",";
											}
											if (!"".equals(cNames) && null != cNames && !"null".equals(cNames)) {
												cNames = cNames.substring(0, cNames.length() - 1);
											}
										} catch (Exception e) {
											e.printStackTrace();
										} finally {
											if (rss != null) {
												try {
													rss.close();
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
											if (statements != null) {
												try {
													statements.close();
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
										}
										/****
										 * 2015/07/24增加 - 郭亮
										 * （配置统计生成时根据配置信息计算后的值不在原数据源中）
										 *****/
										if (!"".equals(cNames)) {
											cbbTabColumns.setColValueName(cNames);
										} else {
											cbbTabColumns.setColValueName(cdata);
										}
										/****
										 * 2015/07/24增加 - 郭亮
										 * （配置统计生成时根据配置信息计算后的值不在原数据源中）
										 *****/
									}
								}
							}
						}
					}
				}
				// 给colValue字段充数据值
				cbbTabColumns.setColValue(cdata);
				if (cbbTabColumns.getColValueName() == null) {
					cbbTabColumns.setColValueName("");
				}
				String colIsDisplay = "";
				if (flagform && !StringUtils.isEmpty(fromarchiveStatus)) {  // 如果有表单则走表单 并且  fromarchiveStatus不为空
					// flag 1-是否添加或编辑显示 2-是否列表显示 3-是否详细显示 4-是否查询显示 0-全部字段显示
					String isMust = (String) colInfo.get("ATTRIBUTE_01");//是否必著
					String isTabDisplay = (String) colInfo.get("ATTRIBUTE_02");//是否列表显示
					String addOrEditDisplay = (String) colInfo.get("ATTRIBUTE_03");//是否添加/编辑显示
					String addOrEditReadOnly = (String) colInfo.get("ATTRIBUTE_04");//是否添加/编辑只读
					String detailDisplay = (String) colInfo.get("COL_IS_DETAIL");//是否详细显示

					//设置必填项  使用CBB_TAB_FORM_CONFIG 的必填项
					if("Y".equals(isMust)){
						cbbTabColumns.setColIsMust(isMust);
					}else{
						cbbTabColumns.setColIsMust("N");
					}
					//SanXiaFiles upate by huangjian start 是否编辑重新赋值
					//是否编辑：Y可编辑 N不可编辑
					//是否只读: Y只读 N：可编辑
					if("Y".equalsIgnoreCase(addOrEditReadOnly)){//是否编辑 Y可以编辑 N只读
						cbbTabColumns.setColIsEdit("N");
					}else{
						cbbTabColumns.setColIsEdit("Y");
					}
					//SanXiaFiles upate by huangjian end
					if ("1".equals(flag)) {//是否添加或编辑显示
							if ("Y".equals(addOrEditDisplay)) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
					} else if ("2".equals(flag)) {//是否列表显示
							if ("Y".equals(isTabDisplay)) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
					} else if ("3".equals(flag)) {//是否详细显示
							if ("Y".equals(detailDisplay)) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
					} else if ("4".equals(flag)) {//是否查询显示
						if ("Y".equals(cbbTabColumns.getColIsSearch())) {
								cbbTabColumnsList.add(cbbTabColumns);
						}
					} else if ("0".equals(flag)) {//全部字段显示
						cbbTabColumnsList.add(cbbTabColumns);
					}
				} else {// 没有保存表单走表结构定义
					colIsDisplay = cbbTabColumns.getColIsDisplay();// 是否可见
					if ("1".equals(flag)) {
						if ("Y".equals(cbbTabColumns.getColIsVisible())) {
							if ("Y".equals(colIsDisplay)) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
						}
					} else if ("2".equals(flag)) {
						if ("Y".equals(cbbTabColumns.getColIsTabVisible())) {
							if ("Y".equals(colIsDisplay)) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
						}
					} else if ("3".equals(flag)) {
						if ("Y".equals(cbbTabColumns.getColIsDetail())) {
							if ("Y".equals(colIsDisplay)) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
						}
					} else if ("4".equals(flag)) {
						if ("Y".equals(cbbTabColumns.getColIsSearch())) {
							if ("Y".equals(colIsDisplay)) {
								cbbTabColumnsList.add(cbbTabColumns);
							}
						}
					} else if ("0".equals(flag)) {
						cbbTabColumnsList.add(cbbTabColumns);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					connectionMan.deleteConnection(poolName, conn);// 释放，但并未断开连接
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		return cbbTabColumnsList;
	}

	/**
	 * 根据数据ID，获取编辑或详细，字段和数据
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @param dataId
	 * @param flag
	 * @param params(p1: key=nodeId)
	 * @return
	 * @throws Exception List<Map<String,Object>>
	 * @throws
	 * HuangJian
	 */
	@Override
	public List<Map<String, Object>> getEditOrDetailFieldsAndDataByIntfsIera(String orgId, String deptId, String sysId, String tableId, String dataId, String flag, Map<String, Object> params) throws Exception {
		String languageCode = "";// 当前语言code
		if (null != params && params.containsKey("languageCode")) {
			languageCode = String.valueOf(params.get("languageCode"));
		} else {
			throw new Exception("调用接口时，“languageCode”参数不存在，请检查！");
		}
		String archiveFlag = params.get("archiveFlag")==null?"":params.get("archiveFlag").toString();

		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		CbbTables cbbTables = getCbbTablesById(tableId);
		// List<CbbTabColumns> listc = getFormShowTableList(tableId, dataId, cbbTables.getTableName(), flag, sysId, orgId, deptId, (String) params.get("nodeId"));// 基本字段
		List<CbbTabColumns> listc = getFormShowTableListItera(params, tableId, dataId, cbbTables.getTableName(), flag, sysId, orgId, deptId, (String) params.get("nodeId"));// 基本字段

		for (int i = 0; i < listc.size(); i++) {
			CbbTabColumns cbbTabColumns = listc.get(i);
			String languageLabel = this.commTableManagerIntfsService.getColumnLabelByColumnIdAndLanguageCode(cbbTabColumns.getId(), languageCode);
			// 如果是中文code , 并且label为空,则用系统默认label显示
			if ("zh_CN".equals(languageCode) && (null == languageLabel || "".equals(languageLabel))) {
				languageLabel = cbbTabColumns.getColLabel();
			}
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("ID", cbbTabColumns.getId());
			map.put("TABLE_ID", cbbTabColumns.getTableId());
			map.put("COL_NAME", cbbTabColumns.getColName());
			map.put("COL_LABEL", languageLabel);
			map.put("COL_TYPE", cbbTabColumns.getColType());
			map.put("COL_LENGTH", cbbTabColumns.getColLength());
			map.put("COL_DECIMAL", cbbTabColumns.getColDecimal());
			map.put("COL_IS_SYS", cbbTabColumns.getColIsSys());
			map.put("COL_ORDER", cbbTabColumns.getColOrder());
			map.put("COL_IS_MUST", cbbTabColumns.getColIsMust());
			map.put("COL_IS_VISIBLE", cbbTabColumns.getColIsVisible());
			map.put("COL_IS_SEARCH", cbbTabColumns.getColIsSearch());
			map.put("COL_IS_EDIT", cbbTabColumns.getColIsEdit());
			map.put("COL_IS_TAB_VISIBLE", cbbTabColumns.getColIsTabVisible());
			map.put("COL_IS_DETAIL", cbbTabColumns.getColIsDetail());
			map.put("COL_DROPDOWN_TYPE", cbbTabColumns.getColDropdownType());
			map.put("COL_GENE_METHOD", cbbTabColumns.getColGeneMethod());
			map.put("COL_RULE_NAME", cbbTabColumns.getColRuleName());
			map.put("COL_RULE_TITLE", cbbTabColumns.getColRuleTitle());
			map.put("CUSTOM_PATH", cbbTabColumns.getCustomPath());
			map.put("REMARK", cbbTabColumns.getRemark());
			map.put("IS_COMM_FIELD", cbbTabColumns.getIsCommField());
			if ("date".equals(cbbTabColumns.getColType()) && !"".equals(cbbTabColumns.getColValue()) && null != cbbTabColumns.getColValue()) {
				String date = "";
				if ("3".equals(archiveFlag)){ //档案保管详情页需要显示 推送时间 整理时间 检查时间 入库时间  时分秒
					if ("TSSJ".equals(cbbTabColumns.getColName())||"ZLSJ".equals(cbbTabColumns.getColName())||"JCSJ".equals(cbbTabColumns.getColName())||"RKSJ".equals(cbbTabColumns.getColName())){
						if(cbbTabColumns.getColValue()!=null&&cbbTabColumns.getColValue().indexOf(".")>-1){
							date=cbbTabColumns.getColValue().substring(0,cbbTabColumns.getColValue().indexOf("."));
						}else {
							date = cbbTabColumns.getColValue().substring(0, 10);
						}
					}else {
						date = cbbTabColumns.getColValue().substring(0, 10);
					}
				}else {
					date = cbbTabColumns.getColValue().substring(0, 10);
				}

//				String date = cbbTabColumns.getColValue().substring(0, 10);
				map.put("COL_VALUE", date);
			} else {
				map.put("COL_VALUE", cbbTabColumns.getColValue());
			}
			map.put("COL_VALUE_NAME", cbbTabColumns.getColValueName());
			// SanXiaFiles create by zhaoxiaolong 保管号补位显示
			if (cbbTabColumns.getColName().equals("BGH")){
				String bghValue = "";
				if (cbbTabColumns.getColValue()!=null&&!"".equals(cbbTabColumns.getColValue())){
					int count = Integer.valueOf(cbbTabColumns.getColValue());
					bghValue = String.valueOf(count);
					bghValue = this.getBghStr(bghValue);
				}
				map.put("COL_VALUE",bghValue);
				map.put("COL_TYPE", "string");
			}
			// 添加组合项规则
			String colGeneMethod = cbbTabColumns.getColGeneMethod();
			if ("4".equals(colGeneMethod)) { // 组合项
				String sourceId = cbbTabColumns.getId();// 源字段ID
				String recordId = "";
				if (null != params && params.containsKey("ortherMap")) {
					Map<String, Object> ortherMap = (Map<String, Object>) params.get("ortherMap");
					Iterator it = ortherMap.keySet().iterator();
					while (it.hasNext()) {
						String key = String.valueOf(it.next());
						recordId = String.valueOf(ortherMap.get(key));
					}
				}
				// 组合项信息字符串，页面解析进行填值
				String groupConfig = getConfigStr(sourceId, tableId, recordId);
				map.put("GROUP_CONFIG", groupConfig);
				// 起止日期
				if(cbbTabColumns.getColName().equals("QZRQ")){
					groupConfig = getConfigStr(sourceId, tableId, dataId);
					groupConfig = groupConfig.replace("00:00:00.0","");
					groupConfig = groupConfig.replace(" ","");
					groupConfig = groupConfig.replace("@***&&&**(","");
					map.put("COL_VALUE", groupConfig);
				}
			}
			list.add(map);
		}
		return list;
	}

	/**
	 * 判断查询结果集中是否存在某列
	 * @param rs 查询结果集
	 * @param columnName 列名
	 * @return true 存在; false 不存咋
	 */
	private boolean isExistColumn(ResultSet rs, String columnName) {
		try {
			if (rs.findColumn(columnName) > 0 ) {
				return true;
			}
		}
		catch (SQLException e) {
			return false;
		}

		return false;
	}

	/**
	 * 根据NODE_ID 判断是否为档案类型数据
	 * @param orgId
	 * @param sysId
	 * @param nodeId
	 * @return String
	 * @throws
	 */
	@Override
	public String getArchiveTypeByNodeIdAndTableId(String orgId, String sysId, String nodeId, String tableId){
		if(StringUtils.isEmpty(nodeId)){
			String sql = "SELECT T.NODE_ID FROM CBB_TAB_NODE T WHERE T.TABLE_ID='"+ tableId +"' WHERE ORG_ID='"+ orgId +"' AND SYS_ID='"+ sysId +"'";
			Map<String, Object> nodeIdMap = this.jdbcAvicit.getJdbcTemplate().queryForMap(sql);
			nodeId = nodeIdMap.get("NODE_ID").toString();
		}
		StringBuffer sb = new StringBuffer();
		//sanxiaFiles create by wuliang 2019.9.27 获取对应节点档案类型
		List<Map<String, Object>> archiveTpeMap = jdbcAvicit.getJdbcTemplate().queryForList("WITH t1 AS (\n" +
				"\tSELECT\n" +
				"\t\tT.*,\n" +
				"\t\tSYS_CONNECT_BY_PATH ( T.ID, '/' ) PH \n" +
				"\tFROM\n" +
				"\t\tLANTOP_ARCHIVE_CLASS T CONNECT BY PRIOR T.ID = T.PARENT_ID START WITH T.PARENT_ID = 'ROOT' \n" +
				"\t),\n" +
				"\tT2 AS ( SELECT lac.* FROM LANTOP_ARCHIVE_CLASS LAC WHERE lac.id = '" + nodeId + "' ) SELECT\n" +
				"\tt1.* \n" +
				"FROM\n" +
				"\tt1,\n" +
				"\tt2 \n" +
				"WHERE\n" +
				"\tinstr( t2.ARCHIVE_CLASS_NODE_PATH, t1.ph ) > 0 \n" +
				"\tAND t1.ARCHIVE_TYPE = '2'");

		/*sb.append("SELECT T.ARCHIVE_TYPE");
		sb.append("  FROM LANTOP_ARCHIVE_CLASS T");
		sb.append(" WHERE T.ID = (SELECT PARENT_ID");
		sb.append("                 FROM LANTOP_ARCHIVE_CLASS");
		sb.append("                WHERE ID = '" + nodeId + "'");
		sb.append("                AND SYS_ID='" + sysId + "'");
//		sb.append("                AND ORG_ID='" + orgId +"'");
		sb.append("                )");
		List<Map<String, Object>> archiveTpeMap = this.jdbcAvicit.getJdbcTemplate().queryForList(sb.toString());*/
		//sanxiaFiles create by wuliang 2019.9.27 获取对应节点档案类型 end
		String archive_type=null;
		if (archiveTpeMap!=null&&archiveTpeMap.size()>0){
			archive_type = archiveTpeMap.get(0).get("ARCHIVE_TYPE").toString();
		}
		return archive_type;
	}

	/**
	 * 文件级据dataId查询归档单位和责任者的codeid
	 * @param dataId
	 * @return
	 */
	@Override
	public List<Map<String, Object>> getCode(String dataId,String tableName) {
		String sql = "SELECT T.ARCHIVE_DEPT_ID,T.RESPONSIBLE_USER_ID FROM "+tableName+" T WHERE T.ID = '"+dataId+"'";
		List<Map<String, Object>> codeMap = this.jdbcAvicit.getJdbcTemplate().queryForList(sql);
		if (codeMap==null||codeMap.size()==0){
			codeMap.add(new HashMap<String, Object>());
		}
		return codeMap;
	}


	/**
	 * 根据组织应用ID获取全宗信息
	 * @param orgId
	 * @return
	 */
	public List<Map<String, Object>> getQz(String orgId) {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT T.GENERAL_NAME, T.GENERAL_BEN_CODE\n");
		sbSql.append("  FROM LANTOP_GENERAL_ARCHIVE T\n");
		sbSql.append(" WHERE T.ORG_IDENTITY = '" + orgId + "'");
		List<Map<String, Object>> qzList = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
		return qzList;
	}


	/**
	 * 根据当前节点ID，获取当前分类号
	 * @param orgId
	 * @return
	 */
	public List<Map<String, Object>> getNodeRemarkByNodeId(String nodeId) {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT T.REMARK FROM LANTOP_ARCHIVE_CLASS T WHERE T.ID = '" + nodeId + "'");
		List<Map<String, Object>> flList = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
		return flList;
	}

	/**
	 * 根据表ID，获取所有选择弹出框信息（返回值以英文分号隔开）
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param tableId
	 * @return
	 * @throws Exception
	 *             String
	 * @throws
	 */
	@Override
	public String getSelectDialogStringByIntfs1(String orgId, String deptId, String sysId, String tableId) throws Exception {
		String userDpetString = "";
		String sql = "SELECT T.ID FROM CBB_TAB_COLUMNS T WHERE T.COL_IS_DISPLAY = 'Y' AND T.TABLE_ID ='" + tableId + "' ORDER BY T.COL_ORDER,T.COL_NAME";
		List<Object> colList = hibernateDao.findBySQL(sql);
		// 循环基本字段
		for (int i = 0; i < colList.size(); i++) {
			String cid = String.valueOf(colList.get(i));
			CbbTabColumns cbbTabColumns = new CbbTabColumns();
			cbbTabColumns = getCbbTabColumnsById(cid);
			String colRuleName = cbbTabColumns.getColRuleName();
			String colName = cbbTabColumns.getColName();
			if ("user".equals(colRuleName)) {
				userDpetString = userDpetString + "user," + colName + "_ID," + colName + ",选择用户;";
			} else if ("dept".equals(colRuleName)) {
				userDpetString = userDpetString + "dept," + colName + "_ID," + colName + ",选择部门;";
			}
		}
		return userDpetString;
	}

	@Override
	public String getTableFieldsAndDatasBySearchByOrderbyByIntfsCount(String orgId, String deptId, String sysId, String tableId, String pageNo, String pageSize, String serachCondition, Map<String, Object> param) {
		//Map<String, Object> resultMap = new HashMap<String, Object>();
		//List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

		String sql = "";
		CbbTables cbbTables = getCbbTablesById(tableId);
		// 获取条目是否存在附件状态
		if (null != param && param.containsKey("ATTACH_STATUS") && null != param.get("ATTACH_STATUS") && !"".equals(param.get("ATTACH_STATUS")) && ("1".equals(param.get("ATTACH_STATUS")) || "2".equals(param.get("ATTACH_STATUS")))) {
			sql = "SELECT * FROM (SELECT (SELECT COUNT(1) FROM CBB_DOC_RELATION CDR WHERE CDR.RECORD_ID = T.ID AND CDR.IF_DELETE = 'N') ATTACH_COUNT, T.* FROM " + cbbTables.getTableName() + " T WHERE 1=1 ";
		} else {
			sql = "SELECT * FROM " + cbbTables.getTableName() + " WHERE 1=1 ";
		}
		if (!"".equals(serachCondition)) {
			sql = sql + serachCondition + "  ";
		}
		// 获取排序字段
		// 排序条件
		/*String sortColName = (String)param.get("sortColName");
		String sortDirection = (String)param.get("sortDirection");
		if (null != sortColName && null != sortDirection && !"".equals(sortColName) && !"".equals(sortDirection) && !"null".equals(sortColName) && !"null".equals(sortDirection)) {
			if ("BROWSE_NUM".equals(sortColName)) {
				// 浏览次数排序
				sql = sql +" ORDER BY " + sortColName + " DESC,";
			} else if ("RQ".equals(sortColName)) {
				// 时间排序
				if ("1".equals(sortDirection)) {
					sql = sql +" ORDER BY RQ ASC,";
				} else {
					sql = sql +" ORDER BY RQ DESC,";
				}
			} else {
				// 相关度

			}
		}*/
		/*sql = sql.substring(0, sql.length() - 1);
		List<CbbTabColumns> formShowList = null;// 全部字段对象
		try {
			formShowList = getFormShowTableList(tableId, "", cbbTables.getTableName(), "0", sysId, orgId, deptId, "");
		} catch (Exception e) {
			e.printStackTrace();
		}*/

		// add start by zyh 2015.06.15
		/*List<String> colIds = new ArrayList<String>();
		StringBuffer queryLookupSql = new StringBuffer();
		queryLookupSql.append("SELECT * FROM CBB_TAB_LOOKUP_V T");
		queryLookupSql.append(" WHERE T.COLUMN_ID IN (");*/
		// 获得存在通用代码列的列id
		/*for (int i = 0; i < formShowList.size(); i++) {
			CbbTabColumns ctcs = formShowList.get(i);
			if ("1".equals(ctcs.getColDropdownType()) || "2".equals(ctcs.getColDropdownType())) {
				queryLookupSql.append("'" + ctcs.getId() + "',");
				colIds.add(ctcs.getId());
			}
		}
		String querySql = "";
		if (queryLookupSql.toString().endsWith(",")) {
			querySql = queryLookupSql.substring(0, queryLookupSql.length() - 1) + ")";
		}*/
		// 查询出列中所需通用代码
		/*List<Map<String, Object>> lookupList = new ArrayList<Map<String, Object>>();
		if (colIds.size() > 0) {
			lookupList = this.jdbcAvicit.getJdbcTemplate().queryForList(querySql);
		}*/
		// 创建通用代码map便于赋值
		/*Map<String, Map<String, String>> lookupMapKeyValue = new HashMap<String, Map<String, String>>();
		for (int i = 0; i < colIds.size(); i++) {
			Map<String, String> lookupNameCodeMap = new HashMap<String, String>();
			for (int j = 0; j < lookupList.size(); j++) {
				Map<String, Object> lookupMap = lookupList.get(j);
				if (colIds.get(i).equals(lookupMap.get("COLUMN_ID"))) {
					lookupNameCodeMap.put((String) lookupMap.get("LOOKUP_CODE"), (String) lookupMap.get("LOOKUP_NAME"));
				}
			}
			lookupMapKeyValue.put(colIds.get(i), lookupNameCodeMap);
		}*/
		// add end by zyh 2015.06.15
		/*f (null != param && param.containsKey("ATTACH_STATUS") && null != param.get("ATTACH_STATUS") && !"".equals(param.get("ATTACH_STATUS"))) {
			if ("1".equals(param.get("ATTACH_STATUS"))) {
				sql += ") WHERE ATTACH_COUNT > 0";
			} else if ("2".equals(param.get("ATTACH_STATUS"))) {
				sql += ") WHERE ATTACH_COUNT < 1";
			}
		}*/

		// 构造PAGE对象
		//String sqlPage = "";
		//String sqlCount = "select count(1) from (" + sql + ")";
		String sqlCount = "select count(1) AS TOTAL from (" + sql + ")";
		List<Map<String, Object>> listTotal = jdbcAvicit.queryForMap(sqlCount, null);// 总数量
		return String.valueOf(listTotal.get(0).get("TOTAL"));
	}

	/**
	 *根据案卷ID获取对应文件的ID和卷内序号
	 * 赵晓龙
	 * @param tableName
	 * @param ids
	 * @return
	 */
	@Override
	public List<Map<String, Object>> getArchiveInNumAndIdByFileId(String tableName,String anTableName ,String ids) {
		ids = ids.replaceAll(",","','");
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT WJ.PARENT_ID,WJ.ID,WJ.ARCHIVE_IN_NUM,WJ.TM,AJ.ARCHIVE_CODE FROM "+tableName+" WJ LEFT JOIN "+anTableName+" AJ ON WJ.PARENT_ID=AJ.ID WHERE WJ.PARENT_ID IN (");
		sbSql.append("'"+ids+"') ");
		return this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
	}

	/**
	 * 根据盒号获取存放位置 SanxiaFiles create by zhaoxiaolong
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param nodeId
	 * @param boxCode
	 * @return
	 */
	@Override
	public String getExistenceArchivePositionByBoxCode(String orgId, String deptId, String sysId, String nodeId, String boxCode,String tableName) {
		String archivePosition = "";
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT ARCHIVE_POSITION FROM "+tableName+" WHERE ARCHIVE_POSITION IS NOT NULL AND " +
				" ORG_ID='"+orgId+"' AND DEPT_ID='"+deptId+"' AND NODE_ID='"+nodeId+"' " +
				"AND ARCHIVE_BOX_CODE='"+boxCode+"' AND ROWNUM<2");
		List<Map<String,Object>> listData = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
		if(listData.size()>0){
			 archivePosition = listData.get(0).get("ARCHIVE_POSITION")==null?"":listData.get(0).get("ARCHIVE_POSITION").toString();
		}
		return archivePosition;
	}

	/**
	 * 查找已存在盒号 SanxiaFiles create by zhangrui
	 * @return
	 */
	@Override
	public List<Map<String,Object>> getBoxByTableId(String orgId,String deptId,String tableName,String textName) {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT * FROM(");
		sbSql.append(" select ARCHIVE_BOX_CODE \"text\",to_char(ARCHIVE_BOX_CODE) \"id\",BOX_MODEL \"boxModel\" from ");
		sbSql.append(tableName);
		if(textName.equals("")){
			sbSql.append(" where ARCHIVE_BOX_CODE IS NOT NULL AND BOX_MODEL IS NOT NUll AND ORG_ID='"+orgId+"' GROUP BY ARCHIVE_BOX_CODE,BOX_MODEL ORDER BY ARCHIVE_BOX_CODE DESC");
		}else {
			sbSql.append(" where ARCHIVE_BOX_CODE IS NOT NULL AND BOX_MODEL IS NOT NUll AND ORG_ID='"+orgId+"' AND ARCHIVE_BOX_CODE LIKE '%"+textName+"%'  GROUP BY ARCHIVE_BOX_CODE,BOX_MODEL ORDER BY ARCHIVE_BOX_CODE DESC");
		}
		sbSql.append(") WHERE ROWNUM <=10");
        List<Map<String,Object>> listData = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
		return listData;
	}


	/**
	 * 获取分类号SanxiaFiles create by zhangrui
	 * @param
	 * @return
	 */
	@Override
	public List<Map<String,Object>> getArchiveClassNoBySql(String nodeId,String tableId) {
		StringBuffer sqSql = new StringBuffer();
		CbbTables cbbTables = getCbbTablesById(tableId);// 根据tableId获取基本表对象
		sqSql.append("SELECT ARCHIVE_CLASSNO FROM " + cbbTables.getTableName());
		sqSql.append(" where node_id = '" + nodeId);
		//SanXiaFiles add by huangjian start
		sqSql.append(" AND ARCHIVE_CLASSNO IS NOT NULL \n");
		//SanXiaFiles add by huangjian end
		sqSql.append("' group by ARCHIVE_CLASSNO");
		List<Map<String, Object>> ArchiveClassNo = this.jdbcAvicit.getJdbcTemplate().queryForList(sqSql.toString());
		return ArchiveClassNo;
	}

	@Override
	public void UpdateQzrqByAnIdAndAnTableId(String anId, String anTableId,Map<String,Object> param) {
		StringBuffer sbSql = new StringBuffer();
		if (!"null".equals(anId)&&""!=anId&&anId!=null) {
			if(!"null".equals(anTableId)&&""!=anTableId&&anTableId!=null){
				sbSql.append("SELECT ID FROM CBB_TAB_COLUMNS WHERE COL_NAME='QZRQ' AND TABLE_ID='"+anTableId+"'");
				List<Map<String,Object>> list1 = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
				String soureId = "";
				if(list1.size()>0){
					soureId = list1.get(0).get("ID").toString();
				}
				String configStr="";
				try {
					configStr = this.getConfigStr(soureId,anTableId,anId);
				}catch (Exception e){
					configStr = "";
					e.printStackTrace();
				}finally {
					configStr = configStr.replace("00:00:00.0","");
					configStr = configStr.replace(" ","");
					configStr = configStr.replace("@***&&&**(","");
					sbSql = new StringBuffer();
					sbSql.append("SELECT TABLE_NAME FROM CBB_TABLES WHERE ID = '"+anTableId+"'");
					List<Map<String,Object>> list2 = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
					String tableName = "";
					if(list2.size()>0){
						tableName = list2.get(0).get("TABLE_NAME").toString();
					}
					sbSql = new StringBuffer();
					sbSql.append("UPDATE "+tableName+" SET QZRQ='"+configStr+"' WHERE ID='"+anId+"'");
					this.jdbcAvicit.getJdbcTemplate().update(sbSql.toString());
				}
			}
		}
	}

	/**
	 * 变更案卷页数
	 */
	@Override
	public void UpdateYsByAnIdAndAnTableId(String anId, String tgtAnTableId, String fileIds, String tgtFileTableId, String orgId, String nodeId) {
		String id = "";
		String tgtFileTableSql = "SELECT TABLE_NAME FROM CBB_TABLES WHERE ID = '"+tgtAnTableId+"'";
		String tgtFileTableIdSql = "SELECT TABLE_NAME FROM CBB_TABLES WHERE ID = '"+tgtFileTableId+"'";
		List<Map<String,Object>> list2 = this.jdbcAvicit.getJdbcTemplate().queryForList(tgtFileTableSql);
		List<Map<String,Object>> list1 = this.jdbcAvicit.getJdbcTemplate().queryForList(tgtFileTableIdSql);
		String tableName = "";
		String jnjtableName = "";
		if(list2.size()>0){
			tableName = list2.get(0).get("TABLE_NAME").toString();
		}
        if(list1.size()>0){
            jnjtableName = list1.get(0).get("TABLE_NAME").toString();
        }
		String [] fileIdsArray = fileIds.split(",");
		int i = 0;
		for (String fileId : fileIdsArray){
			id = fileId;
			String wjDocSql = "SELECT C.ATTRIBUTE_04 FROM CBB_DOC_RELATION C WHERE C.RECORD_ID ='"+id+"' AND C.ORG_ID='"+orgId+"'";
			List<Map<String,Object>> dataList = this.jdbcAvicit.getJdbcTemplate().queryForList(wjDocSql);
			for(Map<String,Object> map:dataList){
				if(map.get("ATTRIBUTE_04")==null){
					continue;
				}
				String attribute_04 = map.get("ATTRIBUTE_04").toString();
				i = i+Integer.parseInt(attribute_04);
			}
            String jnjsbSql = "UPDATE "+jnjtableName+" SET ARCHIVE_PAGE_NUM='"+i+"' WHERE ID='"+id+"' AND ORG_ID='"+orgId+"'";
            this.jdbcAvicit.getJdbcTemplate().update(jnjsbSql);
		}
		String sbSql = "UPDATE "+tableName+" SET ARCHIVE_PAGE_NUM='"+i+"',JS='"+fileIdsArray.length+"' WHERE ID='"+anId+"' AND ORG_ID='"+orgId+"'";
		this.jdbcAvicit.getJdbcTemplate().update(sbSql);
	}

	/**
	 * 更新案卷件数
	 * @param resultId
	 * @param anTableId
	 * @param fileTableId
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @throws Exception
	 */
	@Override
	public void UpdateJsByAnIdAndAnTableId(String resultId, String anTableId,String fileTableId,String orgId,String deptId,String sysId) throws Exception{
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT TABLE_NAME FROM CBB_TABLES WHERE ID = '"+anTableId+"'");
		List<Map<String,Object>> list2 = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
		String antableName = "";
		if(list2.size()>0){
			antableName = list2.get(0).get("TABLE_NAME").toString();
		} else {
			return;
		}
		String sql = " AND PARENT_ID = '" + resultId + "'";
		Object obj = this.getOperationTableColDataByIntfs(fileTableId, sql, "ID", orgId, deptId, sysId, "COUNT");
		sbSql = new StringBuffer();
		sbSql.append("UPDATE "+antableName+" SET JS='"+Integer.valueOf(obj.toString())+"' WHERE ID='"+resultId+"'");
		this.jdbcAvicit.getJdbcTemplate().update(sbSql.toString());
	}

	@Override
	public void updateById(String sqlT, String anTableId) {
			StringBuffer upsql =  new StringBuffer();
			CbbTables cbbTables = getCbbTablesById(anTableId);

			upsql.append("UPDATE " + cbbTables.getTableName() + "  " );
			upsql.append("SET ARCHIVE_FLOW_STATUS = -1 ");
			upsql.append("WHERE 1 = 1 " + sqlT);


			this.jdbcAvicit.getJdbcTemplate().execute(upsql.toString());
	}

}



